should be :
(SELECT T.pno as pno , T.cost+C.assemblyCost as cost
FROM CompositeParts C, (SELECT TM.pno1 as pno , ? as cost
FROM TempMadeFrom TM, BaseParts B
WHERE TM.pno2=B.pno
GROUP BY TM.pno1) T
WHERE C.pno=T.pno)
UNION
(SELECT * FROM BaseParts);
tsql-indent will give you
( SELECT T.pno as pno , T.cost+C.assemblyCost as cost
FROM CompositeParts C,
( SELECT TM.pno1 as pno , ? as cost <==
FROM TempMadeFrom TM, BaseParts B
WHERE TM.pno2=B.pno
GROUP BY TM.pno1) T
WHERE C.pno=T.pno) <<===
UNION <<===
(SELECT * FROM BaseParts);
or quite better
( SELECT T.pno as pno , T.cost+C.assemblyCost as cost
FROM CompositeParts C,( SELECT TM.pno1 as pno , ? as cost
FROM TempMadeFrom TM, BaseParts B
WHERE TM.pno2=B.pno
GROUP BY TM.pno1) T
WHERE C.pno=T.pno <<== indent problem
)
UNION <<== indent problem
(SELECT * FROM BaseParts);
I think we have here 2 indent problem , because WHERE is belong to first
select and not to second.
and union belongs to first and third select. not to second one.