I have this query:
select id,number,name
from objects
order by case number when 0 then 1 else -1 end asc
The database is a database of objects with numbers. If an object doesn’t have a number than its number is 0. I want to sort by number ascending, with the exception of when the number is 0, in which case, sort descending.
The query above seems to sort by ID, the default sorting order.
Thank you.
Close, but you forgot to sort by
numberas well: