Page 1 of 1

ORDER by NULLs first then values

Posted: Tue Feb 24, 2009 6:30 am
by someberry
Hello, quick question which I'm not sure is even possible, but I would have a table like with two columns, an ID and a UNIX timestamp when the event is complete, so the table looks something like:

Code: Select all

id          date
1           1234567890
2           NULL
3           6789012345
4           NULL
5           8901234567
However, I would like the query to order the rows with 'NULL' in the date column first and then order the remaining rows by the date DESC, so:

Code: Select all

id          date
2           NULL
4           NULL
1           1234567890
3           6789012345
5           8901234567
Anyone know if this is possible?

Re: ORDER by NULLs first then values

Posted: Tue Feb 24, 2009 7:21 am
by VladSun

Re: ORDER by NULLs first then values

Posted: Tue Feb 24, 2009 7:45 am
by someberry
Perfect! Thanks!