TSQL-Order by

  • Ezpz. Thanks for the question.



    Everything is awesome!

  • Good Monday question. Nice explanation as well.

    Not all gray hairs are Dinosaurs!

  • Nice one....

  • nice question.... πŸ˜€

    Manik
    You cannot get to the top by sitting on your bottom.

  • The explanation says

    In T-SQL the nulls are returned at the beginning of the result set if ordering is specified. Standard SQL supports the options NULLS FIRST and NULLS LAST to control how NULLs sort, but T-SQL doesn’t support this option.

    For me it's clearer to say that NULLS are treated as the lowest possible value. If you ORDER BY DESC then the NULLs appear at the end of the result set. That's not clear to me from the explanation.

    I guess it's just a question of what you mean by 'first' and 'last'. πŸ™‚

  • Good Question. I've never really thought about Nulls being in a Column that I was ordering. In general the "Order by" Columns tend to the most important Columns in the Result and I wouldn't expect them to contain Null.

    David

  • but what order with _the_ null_s_ be returned? no particular order; yes, they both come first, but which before the other? who knows? can't tell.

  • Pretty easy. πŸ™‚

  • kapil_kk (7/14/2013)


    Lokesh Vij (7/14/2013)


    Easy one for Monday morning πŸ™‚

    Thanks Pramod!

    +1 πŸ™‚

    +1

    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

Viewing 9 posts - 16 through 24 (of 24 total)

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