Gediminas Gediminas - 5 months ago 41
MySQL Question

Order by own `position` using sql

I have few hundreds items in table with

position is null
, I want to do an order by position and set
and etc, but also live the other results with same
position is null

the problem is, if I'm ordering
by order by position asc
, first results come where
position is null
and only after them comes results I want to be first. I what that these results with
would go in the end.

Is it possible to solve this only with sql?

select position
from YourTable
order by case 
when position is null 
then 1 else 0 end, position