select id, min(start_date) period_start, max(end_date) period_end from ( select id, start_date, end_date, max(contig) over (partition by id order by end_date) contiguous_group from ( select id, start_date, end_date, case when lag(end_date) over (partition by id order by end_date) != start_date-1 or row_number() over (partition by id order by end_date)=1 then row_number() over (partition by id order by end_date) else null end contig from t2 ) ) group by id, contiguous_group order by id, period_start
oracle 合并连续时间sql
猜你喜欢
转载自wjhu.iteye.com/blog/1591125
今日推荐
周排行