--字段类型
--id
varchar(30)
--id4
varchar(30)
--id3
varchar(30)
--id2
varchar(30)
--id1
varchar(30)
--tsx
dec(10,0)
--bblb
dec(2,0)
--ywlb
dec(2,0)
--cc
int
with tmp (id,id4,id3,id2,id1,tsx,bblb,ywlb,cc) as (
select id,sjid,space(30),space(30),space(30),tsx,bblb,ywlb,1
from table_1
where sjid is null
union all
select t1.id,t1.sjid,t2.id4,t2.id3,t2.id2,t1.tsx,t1.bblb,t1.ywlb,t2.cc+1
from table_1 t1
,tmp t2
where t1.sjid = t2.id
)
selectid
,id4
,id3
,id2
,id1
,tsx
,bblb
,ywlb
,cc
from tmp
;
|