SQL 查询 如何查询最初单据编号

2025-03-23 04:52:39
推荐回答(1个)
回答1:

;with temp as
(select a as 原始单号,a as 当前单号 from table1 where a='9051'
union all
select temp.原始单号 as 原始单号,table1.b as 当前单号 from table1
inner join temp on temp.当前单号=table1.a )

select * from temp