这样的一批数据,希望按照ht排序,再按照是否连续时间段分组.
select * from (
select '001' ht,800 dk,to_date('2013-09-17','yyyy-MM-dd') t1, to_date('2013-09-20','yyyy-MM-dd')t2 from dual
union
select '001' ht,750 dk,to_date('2013-09-21','yyyy-MM-dd')t1 , to_date('2013-10-20','yyyy-MM-dd') t2 from dual
union
select '001' ht,2000 dk,to_date('2013-09-18','yyyy-MM-dd')t1 , to_date('2013-09-20','yyyy-MM-dd') t2 from dual
union
select '002' ht,1500 dk,to_date('2013-09-21','yyyy-MM-dd')t1, to_date('2013-10-20','yyyy-MM-dd') t2 from dual
) order by ht ,t1
现在对于按时间段连续排序问题无法下手,补充说明连续的相差一天,其他的会有交集。也就是ht排序,连续与非连续的时间段分组。