|
发表于 2023-2-22 17:57
来自手机
|
显示全部楼层
emaildai78 发表于 2023-2-22 14:16
两个相邻的不用缩,3个或3个以上才用“-”连接,
//select * from 带字母数字离散转连续数据;
cli_split_data~带字母数字离散转连续数据~,~位号;
create temp table aa2 as
select *,regexp2('(\D+)(\d+)',位号,1) 前缀,regexp2('(\D+)(\d+)',位号,2) 原始 from 带字母数字离散转连续数据split order by id;
create temp table aa3 as select *,原始-row_number() over (partition by id,前缀) 差 from aa2;
create temp table aa as
select *,iif((select count(*) from aa3 a where a.id=b.id and a.前缀=b.前缀 and a.差=b.差)>2,1,rowid) 计数 from aa3 b;
create temp table bb as select id,原始,差,iif(min(原始)!=max(原始) and (max(原始)-min(原始)>2),前缀||min(原始)||'-'||前缀||max(原始),前缀||原始) 新序号 from aa group by id,前缀,差,计数;
select a.rowid,位号,新序号 from 带字母数字离散转连续数据 a join (select id,group_concat(新序号) 新序号 from bb group by id) b on a.rowid=b.id;
|
|