将下面的1,2,3,4,5 变成 1-2,2-3,3-4这种吗?
好像可以用sql 解决
代码如下:
with tmp_data as (
select 1 id, 31 val1, 331 val2 from dual union all
select 2 id, 32 val1, 332 val2 from dual union all
select 3 id, 33 val1, 333 val2 from dual union all
select 4 id, 34 val1, 334 val2 from dual union all
select 5 id, 35 val1, 335 val2 from dual
)
select a.id,lead(a.id,1,b.id) over (order by a.id) next_id ,a.id||'-'||lead(a.id,1,b.id) over (order by a.id) category_new, a.val1,a.val2 from tmp_data a
left join (select max(id)+1 id from tmp_data ) b on 1=1