Thanks for your reply, but when I will have a dataset like below :
Tgt Src lvl
============ ============ ====
L4_Tab1.Col1 L3_Tab2.Col3 0
L4_Tab1.Col4 L3_Tab2.Col1 0
L4_Tab1.Col2 L3_Tab1.Col2 0
L4_Tab1.Col3 L3_Tab1.Col3 0
L3_Tab2.Col1 L2_Tab2.Col3 1
L3_Tab1.Col2 L2_Tab2.Col2 1
L3_Tab2.Col3 L2_Tab1.Col3 1
L3_Tab1.Col3 L2_Tab2.Col3 1
L2_Tab2.Col3 L1_Tab3.Col3 2
L2_Tab1.Col3 L1_Tab3.Col1 2
L2_Tab2.Col2 L1_Tab2.Col2 2
L2_Tab1.Col3 L1_Tab1.Col1 2
L2_Tab2.Col2 L1_Tab1.Col2 2
L2_Tab2.Col2 L1_Tab3.Col2 2
I have to write a query like below :
SELECT a.Tgt, a.Src, b.Src AS Lvl_1, c.Src AS Lvl_2
FROM SRCTGTMAP a
INNER JOIN SRCTGTMAP b
ON a.Src = b.Tgt
AND a.lvl+1 = b.lvl
INNER JOIN SRCTGTMAP C
ON b.Src = c.Tgt
AND b.lvl+1 = c.lvl
ORDER BY 1
Means I have to use the same table again in inner join to get another level.
Can this be done with a query which can work in any (multiple) level?
Regards,
Koushik
Thanks for your reply, but when I will have a dataset like below :
I have to write a query like below :
Means I have to use the same table again in inner join to get another level.
Can this be done with a query which can work in any (multiple) level?
Regards,
Koushik