日期:2014-05-17  浏览次数:20960 次

order by 排序问题!
打个比方说,"select * from table order by point_id,date"
在上面语句中,先是根据point_id排序,再是根据date排序.
我想问的是,在point_id里面,我还要按照(SZLY%,SZHG%,ZSSL%)这样的顺序进行排序了,我该怎么做呢?

------解决方案--------------------
order by decode(substr(point_id,1,4),'SZLY','0','SZHG','1','ZSSL','2',substr(point_id,1,4))||substr(point_id,5), date

函数排序,把前四个字符取出来,指定下顺序,再把剩下的部分带上就行了
------解决方案--------------------
能否贴点数据?

------解决方案--------------------
have a try using the following sql

select * from table
where point_id like 'SZLY%'
order by point_id,date

union

select * from table
where point_id like 'SZHG%'
order by point_id,date


union

select * from table
where point_id like 'ZSSL%'
order by point_id,date

union

......