June 17, 2017 at 11:28 pm
Comments posted to this topic are about the item SELECT with DISTINCT and TOP
God is real, unless declared integer.
June 19, 2017 at 4:42 am
Thanks Thomas for this question. Yes, back to the basics, but I still looked into MSDN before answering ...😉
June 19, 2017 at 4:57 am
Nice question. Thanks.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 19, 2017 at 5:55 am
I always get the order of these two confused, because it's one of the places where SQL diverges from English.
In English, DISTINCT TOP 5 would mean "get the distinct values of the top five results" -- which with this data set would return only one row (1), whereas TOP 5 DISTINCT clearly means "get the top 5 values of the distinct results."
SQL uses the first syntax, but to mean the second instruction.
June 19, 2017 at 9:14 am
Thanks for this instructive question.
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
June 19, 2017 at 10:25 am
Nice - thanks, Thomas!
June 20, 2017 at 2:04 am
Nice, simple question, thanks Thomas
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply