oracle有序的合并函数,Oracle 合并连续日期时间段

表结构:

e07939b6264cd103fd71710b1cf5e4a5.png 表数据:

oracle有序的合并函数,Oracle 合并连续日期时间段_第1张图片 查询结果:

oracle有序的合并函数,Oracle 合并连续日期时间段_第2张图片 SQL代码:

with temp as ( select t.xmbh,

t.ygbh,

t.bjje,

t.ssrq,

lead(ssrq, 1, ssrq) over(partition by xmbh order by ssrq) next_ssrq,

lag(ssrq, 1, ssrq) over(partition by xmbh order by ssrq) prev_ssrq,

lead(t.bjje) over(partition by xmbh order by ssrq) next_bjje,

lag(t.bjje) over(partition by xmbh order by ssrq) prev_bjje

from ( select 1 as resource_id,'TEMP1' as xmbh, &

你可能感兴趣的:(oracle有序的合并函数)