• Thomas Franz

    Hall of Fame

    Points: 3565

    Comments posted to this topic are about the item SELECT with DISTINCT and TOP

    God is real, unless declared integer.

  • George Vobr

    SSCrazy Eights

    Points: 8999

    Thanks Thomas for this question. Yes, back to the basics, but I still looked into MSDN before answering ...😉

  • Kingston Dhasian


    Points: 19794

    Nice question. Thanks.

    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden

  • sknox


    Points: 12231

    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.

  • webrunner

    One Orange Chip

    Points: 29955

    Thanks for this instructive question.

    A SQL query walks into a bar and sees two tables. He walks up to them and says Can I join you?

  • Revenant


    Points: 42467

    Nice - thanks, Thomas!

  • Stewart "Arturius" Campbell

    SSC Guru

    Points: 71452

    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 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply