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
 General SQL Server Forums
 New to SQL Server Programming
 Using Calculated Field in Where Clause

Author  Topic 

majawar
Starting Member

1 Post

Posted - 2007-07-23 : 05:47:32
Dear All;

i want to use a calculated field in where clause but this does'nt works: e.g.;

select (colA + colB) as calcField
from tbl
where calcField > 100


what is the right way to do it, as i m getting error;
it works like :
select (colA + colB) as calcField
from tbl
where (colA + colB) > 100


but i m using a complex query as i m getting value from a function and then i hav to use that in where clause as well ;


Thanx in advance,


--
Muhammad Zeeshan

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-23 : 05:50:43
you can also use a derived table

SELECT calcField
FROM
(
SELECT (colA + colB) AS calcField
FROM tbl
) d
WHERE calcField > 100



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -