0
我需要在運行標識級聯就像運行平衡或總.. 串聯以前的ID,以當前ID行明智仿如顯示在畫面SQL ID串聯喜歡跑步總
查詢
with relation (Id, [orderSequence])
as
(
select Id,cast(Id as varchar(20))
from [ACChartofAccount]
union all
select p.Id, cast(Cast(r.Id as varchar) + ',' + cast(p.Id as varchar) as varchar(20))
from [ACChartofAccount] p
inner join relation r on p.ParentId = r.Id
)
select Id,orderSequence
from relation
order by orderSequence
您正在使用哪些DBMS? –
沒有模式,它是非常不清楚的。無論如何檢查** [DEMO](http://rextester.com/RKSS5575)** – lad2025
@a_horse_with_no_name我猜SQL Server基於SSMS screenshoot :) – lad2025