Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 syntax question
 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

38200 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  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000