--向下递归
with temp (OrgId,ParentId,OrgName)
as
(
select OrgId,ParentId,OrgName from Org
where OrgId='01'
union all
select a.OrgId, a.ParentId,a.OrgName from Org a
inner join temp on a.[ParentId] = temp.[OrgId]
)
select * from temp
SQL SERVER 递归查询实现BOM多阶报表

 


 

 
--向上递归
with temp (OrgId,ParentId,OrgName)
as
(
select OrgId,ParentId,OrgName from Org
where OrgId='0405'
union all
select a.OrgId, a.ParentId,a.OrgName from Org a
inner join temp on a.[OrgId] = temp.[ParentId]
)
select * from temp

SQL SERVER 递归查询实现BOM多阶报表

 转发地址:https://www.cnblogs.com/yuyuefly/p/9684593.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2021-08-01
  • 2022-12-23
  • 2021-08-14
  • 2021-08-05
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2018-12-23
  • 2021-07-09
  • 2022-01-19
  • 2022-12-23
相关资源
相似解决方案