select nvl(i,0) As i from tablename order by i
这个就能得到0,1,2,3,8
没有nvl函数用select (case when i is null then 0 else i end) As i from tablename order by i
结果都是0,1,2,3,8
这个就能得到0,1,2,3,8
没有nvl函数用select (case when i is null then 0 else i end) As i from tablename order by i
结果都是0,1,2,3,8
from T
order by 1
SQL SERVER :
select tt.i, case when 8 then 4 else tt.i end
from
(
select isnull(t.i,0)
from t
order by t.i
) tt
order by tt.i
from Tb
order by i