从表中获取HIERARCHY数据 [英] getting HIERARCHY data from a table

查看:62
本文介绍了从表中获取HIERARCHY数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



对于银行应用程序,我需要一个查询,该查询将从底部到顶部检索所有匹配的列数据

我有桌子

在表1中我有




for banking application , i need a query which retrive all the matched column data from bottom to top

i have tho tables

in table 1 i have


Group_Id    Group_Name            Primary_Group_Id
1            assets                    null  
2            liabilities               1
3            fixed                     2
4            expenses                  3
...



表2



table 2

ID   Group_Id
948   3
955   2 



我的要求是,我将传递ID = 948,并且需要从
的底部到顶部获取总的HIERARCHY数据. 表1

结果:我想要以下内容作为输出



my requirement is , i will pass the ID=948 and i need to get the total HIERARCHY data from the bottom to top of
table 1

result: i want the following as output

ID   Group_Id  Group_Name  Primary_Group_Id  Group_Name    Group_Id  Group_Name
948  3         Fixed           2             liabilities    1        assets

推荐答案

请参阅以下提示:
使用递归CTE构建层次结构 [
See the following tip :
Building hierarchy using Recursive CTE[^]

It should give you a start.

Cheers


这篇关于从表中获取HIERARCHY数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆