March 3, 2014 at 9:27 pm
Comments posted to this topic are about the item Order By Column
March 3, 2014 at 11:24 pm
Option 3
Hope this helps...
Ford Fairlane
Rock and Roll Detective
March 4, 2014 at 12:13 am
Nice question, but the explanation doesn't mention why the order of casting vs order by changes. (because of adding the T alias in the second statement)
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 4, 2014 at 1:37 am
This was removed by the editor as SPAM
March 4, 2014 at 1:47 am
Koen Verbeeck (3/4/2014)
Nice question, but the explanation doesn't mention why the order of casting vs order by changes. (because of adding the T alias in the second statement)
+ 1
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
March 4, 2014 at 1:48 am
Interesting QotD.
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
March 4, 2014 at 2:02 am
Good one! thanks.
---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
March 4, 2014 at 2:16 am
Nice qotd.
March 4, 2014 at 3:23 am
Interesting, I never realised that you could order by a column alias.
I have to admit that I assumed that the same principle of not being able to use column aliases in WHERE, HAVING, GROUP BY, etc. clauses would apply.
Nice to know that's not the case though.
March 4, 2014 at 3:34 am
nice question .... but Who Cares 😛
March 4, 2014 at 4:23 am
twin.devil (3/4/2014)
nice question .... but Who Cares 😛
Still remember the pale face of a report developer who wants his data sorder in descending date order, but it was showing in descending string order. 😉
Nice to see that the third option is a valid answer:hehe:
March 4, 2014 at 5:24 am
+1. However, it was an interesting one. Thanks for the question.
March 4, 2014 at 6:17 am
Argh, you got me. Good question!
Yet another reason to add to my list for always prefixing table names or aliases.
March 4, 2014 at 6:47 am
Koen Verbeeck (3/4/2014)
Nice question, but the explanation doesn't mention why the order of casting vs order by changes. (because of adding the T alias in the second statement)
That explanation is important for this question and would have made the question better.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
March 4, 2014 at 7:59 am
Koen Verbeeck (3/4/2014)
Nice question, but the explanation doesn't mention why the order of casting vs order by changes. (because of adding the T alias in the second statement)
I remember being confused by this many years ago (won't say how many :-D) when I first encountered it. Hopefully this post will help alleviate some frustration.
When the table alias is included in the ORDER BY clause, the table field value is used to order the records. When it is not, the alias (i.e. the calculated value) is used to order the records.
Viewing 15 posts - 1 through 15 (of 36 total)
You must be logged in to reply to this topic. Login to reply