Hi,Below is my sample table and dataWith Item as(Select 1 as ItemId,'ItemName1' as ItemName,100 as position union allSelect 2 as ItemId,'ItemName2' as ItemName,200 as position union allSelect 3 as ItemId,'ItemName3' as ItemName,300 as position union allSelect 4 as ItemId,'ItemName4' as ItemName,400 as position union allSelect 5 as ItemId,'ItemName5' as ItemName,500 as position union allSelect 6 as ItemId,'ItemName6' as ItemName,600 as position union allSelect 7 as ItemId,'ItemName7' as ItemName,700 as position),Mapping as (Select 1 as Parent, 2 as child union allSelect 1 as Parent, 3 as child union allSelect 1 as Parent, 4 as child union allSelect 5 as Parent, 6 as child union allSelect 5 as Parent, 7 as child )
Expected Result: ParentItemId ParentItemName Parentposition ChildItemId ChildItemName Childposition1 ItemName1 100 2 ItemName2 2001 ItemName1 100 3 ItemName3 3001 ItemName1 100 4 ItemName4 4005 ItemName5 500 6 ItemName6 6005 ItemName5 500 7 ItemName7 700I was thinking to achieve using union all but if i use union all it will combine the result in rows level. but i need in column level. Any help please