SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TSQL-Order by


TSQL-Order by

Author
Message
david.irvine 7489
david.irvine 7489
Right there with Babe
Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)Right there with Babe (796 reputation)

Group: General Forum Members
Points: 796 Visits: 1576
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'. :-)
David Conn
David Conn
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3169 Visits: 1152
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
bobby-robbins
bobby-robbins
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 4
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.
sqlnaive
sqlnaive
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4353 Visits: 2774
Pretty easy. :-)
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33422 Visits: 18560
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search