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

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Declaring AS expressions

Author  Topic 

JP_xpto
Starting Member

10 Posts

Posted - 2002-11-11 : 07:20:40
I think this is a begginer thing...;)
Supose i have this query:

SELECT (XXXXXX-YYYYYY) as Myproblem
FROM TABv
WHERE Myproblem <>0

Is any way i can do that without declaring again the (XXXXXX-YYYYYY) in the 3 line of the query? I just want to say Myproblem <> 0.

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-11-11 : 07:33:23
No sorry. You can't do it that way, you have to re-evaluate the expression.

You can use the alias in an Order By statement though.

Damian
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-11 : 07:41:37
You could do this

select * from
(
SELECT (XXXXXX-YYYYYY) as Myproblem
FROM TABv
)
thing
WHERE Myproblem <>0


Go to Top of Page

JP_xpto
Starting Member

10 Posts

Posted - 2002-11-12 : 04:27:54
Tks, thats all i want to know.

Go to Top of Page
   

- Advertisement -