I know this is going to be another easy question for the SQL gurus since I'm sure I'm doing something wrong that is obvious. This is all for SQL Server 2000 (inherited projects!)
I have a query like
SELECT (SELECT Price1 from Table1) AS 'PriceOne',
(SELECT Price2 From Table2) AS 'PriceTwo',
PriceTwo * PriceOne AS 'Total'
But this generates an error of an unrecognized column for PriceOne and PriceTwo. I'm assuming its possible to multiply columns in this way, right?
First of all, you need to be sure that those sub-querys are always going to return just one row. Now, for your specific issue about the column names, you need to wrapped them on another SELECT
to use them like that:
SELECT PriceOne, ProceTwo, PriceTwo * PriceOne AS 'Total'
FROM ( SELECT (SELECT Price1 from Table1) AS 'PriceOne',
(SELECT Price2 From Table2) AS 'PriceTwo') AS A