Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating column from another column

Status
Not open for further replies.

minli98

IS-IT--Management
Aug 30, 2005
178
US
Hi all,

I have a very basic question. Suppose I do a query to produce 3 columns: A, B and C. A and B are the results of functionA and functionB respectively. C is the sum of B and C.

So I would try,

Code:
select functionA(x) as A, functionB(x) as B, C = A + B
from tableName

But this gives me an error saying that A and B are invalid column names. How can I calculate C? Do I have to do C = functionA(x) + functionB(x) which is repetitious?

Thank you very much.

Regards,
Min
 
I believe you will have to do "C = functionA(x) + functionB(x) " as you have said, yes repetitious. I am guessing sql server doesn't recognize the A and B alias names until the query is complete. Maybe some guru can confirm or shoot down my explination. :)


Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top