December 18th, 2003, 01:42 PM
sorting with NULLs at bottom
I have a result set that I'm sorting by a nullable field. By default it puts the nulled rows at the top. I want them at the bottom without changing the order of the non-nulled rows.
One way that I've thought to do this is some kind of combination of these queries:
SELECT * from myTable
WHERE NOT (myField IS NULL )
ORDER BY myField
SELECT * FROM myTable WHERE myField IS NULL
I suppose there's some kind of join construct for this, but I don't know it.
Any help would be appreciated.
December 18th, 2003, 01:49 PM
by case when myField is null then 1 else 0 end