Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

TSQL-Order by Expand / Collapse
Author
Message
Posted Wednesday, July 17, 2013 2:13 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 3:13 AM
Points: 362, Visits: 785
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'.
Post #1474438
Posted Tuesday, July 23, 2013 12:51 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 2:20 PM
Points: 2,136, Visits: 870
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
Post #1476368
Posted Tuesday, July 23, 2013 7:16 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 23, 2013 9:17 PM
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.
Post #1476852
Posted Wednesday, July 24, 2013 7:32 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, September 4, 2014 7:40 AM
Points: 3,545, Visits: 2,652
Pretty easy.
Post #1477053
Posted Thursday, July 25, 2013 10:20 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 5:20 PM
Points: 17,600, Visits: 15,462
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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1477610
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse