昇順のソートでnullを最後に、 降順でソートでnullを最初に表示する
#■■■昇順でnullを最後に■■■ select Val from (select 1 as Val union select 2 union select 3 union select 4 union select 5 union select null) dummy order by Val is null,Val; #■■■降順でnullを最初に■■■ select Val from (select 1 as Val union select 2 union select 3 union select 4 union select 5 union select null) dummy order by Val is not null,Val desc;
比較演算が1,0を返すことを使ってます