SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 syntax question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

126 Posts

Posted - 10/02/2006 :  16:26:32  Show Profile  Reply with Quote
if I have something like this

select x.a,x.b,(x.c+x.d+x.e) as result, result-x.a
from table

that won't work, because result is an invalid column name in this case.
How can I write this so I don't have to do this:

select x.a,x.b,(x.c+x.d+x.e) as result, (x.c+x.d+x.e)-x.a
from table


Almighty SQL Goddess

38176 Posts

Posted - 10/02/2006 :  16:31:57  Show Profile  Visit tkizer's Homepage  Reply with Quote
select result, result - a
from (select x.a,x.b,(x.c+x.d+x.e) as result, x.a from table) t

Tara Kizer
Go to Top of Page

Posting Yak Master

126 Posts

Posted - 10/02/2006 :  16:42:24  Show Profile  Reply with Quote
many thanx
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000