Hi All,
Oracle version - 19c
I have a table with item and subitem, One item can have many subitems and also subitem can be a part of item but it can be a part of item where it was a subitem.
Data is shown below for reference:
with test as
( select 328666 item, 118331 sub_item from dual union all
select 328666 item, 116716 sub_item from dual union all
select 328666 item, 113453 sub_item from dual union all
select 328666 item, 100049 sub_item from dual union all
select 609920 item, 123491 sub_item from dual union all
select 609920 item, 136945 sub_item from dual union all
select 609920 item, 109049 sub_item from dual union all
select 100049 item, 111208 sub_item from dual union all
select 100049 item, 101350 sub_item from dual union all
select 100049 item, 328666 sub_item from dual
)
select item,sub_item from test;
O/P
Item sub_item
100049 328666
Actually Item 328666 have 4 sub items and out of these one of the sub item becomes a
parent for this