Click here to Skip to main content
15,892,199 members
Home / Discussions / Database
   

Database

 
QuestionHaving a bad SQL day Pin
TheComputerMan12-Feb-13 23:40
TheComputerMan12-Feb-13 23:40 
AnswerRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 0:20
professionalJörgen Andersson13-Feb-13 0:20 
GeneralRe: Having a bad SQL day Pin
TheComputerMan13-Feb-13 0:32
TheComputerMan13-Feb-13 0:32 
GeneralRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 0:40
professionalJörgen Andersson13-Feb-13 0:40 
GeneralRe: Having a bad SQL day Pin
Bernhard Hiller13-Feb-13 3:24
Bernhard Hiller13-Feb-13 3:24 
GeneralRe: Having a bad SQL day Pin
TheComputerMan13-Feb-13 3:33
TheComputerMan13-Feb-13 3:33 
AnswerRe: Having a bad SQL day Pin
Shameel13-Feb-13 0:53
professionalShameel13-Feb-13 0:53 
To add to Jorgen's answer, I've always wondered why SQL Server doesn't allow us to use alias in WHERE and HAVING clauses. The answer to that lies in the logical order in which the query is processed. The WHERE and HAVING clauses are processed before the SELECT clause and the alias do not exist at that stage.

However, technically it should be possible to introduce another stage earlier in the query processing pipeline where a mapping between expressions and their alias is made and WHERE and HAVING clauses can look up to these mappings and substitute the actual expression in place of the alias.
GeneralRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 0:56
professionalJörgen Andersson13-Feb-13 0:56 
GeneralRe: Having a bad SQL day Pin
PIEBALDconsult13-Feb-13 4:01
mvePIEBALDconsult13-Feb-13 4:01 
GeneralRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 6:27
professionalJörgen Andersson13-Feb-13 6:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.