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 |
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2008-02-09 : 10:16:58
|
| Hello !I wonder if I may use aliases in the Where part ? this is not accepted : SELECT isnull((SELECT SUM(dbo.Answer.Evaluation) AS FIELD_2 FROM dbo.Answer WHERE(dbo.Answer.Question_ID = Quest.ID) AND(dbo.Answer.QuizUser_ID = 6)), 0) AS EvalutationResult, Quest.ID AS Question_IDFROM dbo.Question QuestWHERE (Quiz_ID = 8) and EvalutationResult < 5dORDER BY EvalutationResultBut I do not want to repeat all the stuff of EvoalutionResult once again. Any idea?Thanks a lot for any suggestion!Regards, Fabianusmy favorit hoster is ASPnix : www.aspnix.com ! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-09 : 10:22:10
|
| Nope you cant use Aliases in where clause. You need to repeat entire thing. However you can use them in ORDER BY Clause. |
 |
|
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2008-02-09 : 10:52:18
|
| Thanks Visakh16 ! Have a nice day, Fabianusmy favorit hoster is ASPnix : www.aspnix.com ! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-11 : 04:49:10
|
| or use derived table SELECT * from(isnull((SELECT SUM(dbo.Answer.Evaluation) AS FIELD_2 FROM dbo.Answer WHERE(dbo.Answer.Question_ID = Quest.ID) AND(dbo.Answer.QuizUser_ID = 6)), 0) AS EvalutationResult,Quest.ID AS Question_IDFROMdbo.Question QuestWHERE(Quiz_ID = 8) ) as twhere EvalutationResult < 5dORDER BY EvalutationResultMadhivananFailing to plan is Planning to fail |
 |
|
|
fabianus76
Posting Yak Master
191 Posts |
Posted - 2008-02-11 : 04:58:48
|
| Hey Madhivanan, of course - silly me. Thanks a lot for this hint !Regards, Fabianusmy favorit hoster is ASPnix : www.aspnix.com ! |
 |
|
|
|
|
|