Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting question...

Status
Not open for further replies.

captlid

Technical User
Oct 27, 2004
82
US
I have two columns, one is an int and the other is a date,
I want the records to show first the null values in the int column and have that sorted by date, then the rest of the rows sorted by date.

I tried doing

order by int asc, date asc, but it only orders the null values properly.

so this should be the result:
date, int
3/12 null
3/13 null
3/8 5
3/9 4
3/10 4
3/11 5

thanks
 
Code:
order by case when intColumn is null then 0 else 1 end,
dateColumn
 
i didnt know you can put queries inside the order by clause, cool thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top