Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interview questions
Message
 
 
To
25/05/2009 13:13:57
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01380550
Message ID:
01442030
Views:
88
>>>As a follow-up, the "why" is becuase the result (with the alias name) hasn't been created.....
>>>
>>>That's why you can use expression aliases in an ORDER BY....becuase the result set has already been created (sort of), and the database engine can refer to any alias names. But prior to that (i.e. in a GROUP BY), it's too early to use aliases.
>>
>>Now I see.
>>
>>For instance, you can use Row_Number() result in ORDER BY but not in the WHERE expression, AFAIK.
>
>I have in my notes processing in this order (my notes are old though so it may not be true anymore):
>
>1. From clause
>2. Where clause
>3. Group By Clause
>4. Having Clause
>5. Select clause (this is where the alias names come to 'be.')
>(Left out order by which is operated on the cursor so it would be #6)
>
>Can anyone update it? Is it different now? This is from 2004.

Hi Tracy,

Here is an article explaining the logical order

http://pratchev.blogspot.com/2007/05/anatomy-of-query.html
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform