Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql query null

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2011-11-16 : 04:53:49
i need to select records like select * from abc order by 1, 2
but when query fires the record set gives the null values on top, i need the null values at last

challenge everything

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-11-16 : 04:58:38
Try this

select * from abc
order by case when col1 is null then 1 else 0 end , 2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-16 : 05:44:31
shouldnt equivalent be?

select * from abc
order by case when col1 is null then 1 else 0 end, 1, 2


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -