|
发表于 2023-7-24 15:25
来自手机
|
显示全部楼层
本帖最后由 zpy2 于 2023-7-24 15:36 编辑
cli_add_css~td{text-align:left};
create temp table aa as
select 展开层,rowid 子,(select max(rowid) from bom展开填充层级号 a where length(a.展开层)=(length(b.展开层)-1) and a.rowid<b.rowid) 父 from bom展开填充层级号 b order by rowid;
create temp table bb as
select *,row_number() over ( partition by 父,展开层 order by rowid) 描述 from aa;
with recursive under_alice(展开层,父,子,描述) as (select 展开层,父,子,描述 from bb where 子=2 union all select aa.展开层,aa.父,aa.子,under_alice.描述||'.'||aa.描述 from bb aa join under_alice on under_alice.子=aa.父 order by 子)
select 展开层,描述 from under_alice;
|
|