A table of about 200 rows, 15 of which will have a numeric value rankClass (1-15). The rest will have NULL values.
ORDER BY rankClass,nameLast
It posts the rows with NULL values first, and when I add DESC, of course, it lists it set rows first, but 15-1. I'd like it to list those with values first, 1-15, then the rest by nameLast.
I've tried coalesce, but it goes 1,10,11,12,13,14,15,2,3,4,5,6,7,8,9.
How would I get the results I'm looking for?
Thank you.
You could explicitly check for null
s in the rankClass
, and order by an expression that moves them to the end:
SELECT *
FROM mytable
ORDER BY rankClass IS NULL, -- false comes before true
rankClass
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments