>>>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