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.
| Author |
Topic |
|
emzzz
Starting Member
15 Posts |
Posted - 2007-08-23 : 12:10:43
|
| Hello,When you rename a field/calculation in the select part of the sql statement, how do you reference it in the where clause?For example:Select A, B, (C + D) as XFrom testWHERE X > 1Many thanks! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-23 : 12:14:42
|
Select A, B, (C + D) as XFrom testWHERE (C + D) > 1select a, b, x from (Select A, B, (C + D) as XFrom test) as dWHERE x > 1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-24 : 04:47:18
|
quote: Originally posted by emzzz Hello,When you rename a field/calculation in the select part of the sql statement, how do you reference it in the where clause?For example:Select A, B, (C + D) as XFrom testWHERE X > 1Many thanks!
Note that you cant use alias name directly in where or group by clause but you can use it only in order by clauseSelect A, B, (C + D) as XFrom testorder by XMadhivananFailing to plan is Planning to fail |
 |
|
|
emzzz
Starting Member
15 Posts |
Posted - 2007-08-24 : 04:59:09
|
| Many thanks! |
 |
|
|
|
|
|
|
|