我有一个字典表,其中状态相关信息查出如下:
select D_SORT, D_TEXT from BR_DICT  where D_TYPE like '%状态%'
order by D_SORT;
20160613_1
我先想根据任意指定的顺序对该列表进行排序,期望结果如下:
20160613_2
可以使用order by instr或者order by decode两种方式进行实现,
select D_SORT, D_TEXT from BR_DICT  where D_TYPE like '%状态%'
order by instr('321054',CAST(D_SORT as NCHAR));
select D_SORT, D_TEXT from BR_DICT where D_TYPE like '%状态%'
order by decode(D_SORT, '3', '1', '2', '2', '1', '3', '0', '4', '5', '5', '4', '6');

发表评论

邮箱地址不会被公开。 必填项已用*标注