oracle 排序指定某个数据排在第一位

select * from f_area ar where ar.status=1 and ar.parent_id=-1
ORDER BY DECODE(ar.area_code,'3101','1',ar.area_code)
---指定3101的排在第一位


select userid from tb
order by decode(userid,'f',null,userid) nulls first
--排序的时候如果是f的话转换成null 其他的不变
--nulls first表示null排在前面 nulls last 表示null排在后面

猜你喜欢

转载自lanyan-lan.iteye.com/blog/2381180