Some questions:
So your items are at
level1, level3 , level4 , ...
and
your
subaccounts on
level2,level4,level6, ... ???
If so what is the maximum level
And you are searching for all subaccounts or are you searching for all-subaccounts of an item ?
If the last is true are you searching for a particular item, or do you want all items listed with there unique
subaccount.
To give it a try: if the item. subaccount paires start at level 5 and end at level 10
Finding all unique paires :
select distinct item, subaccount
from
(
select level5 item, level6 subaccount from tablex
union
select level7, level8 from tablex
union
select level9, level10 from tablex
)
order by item,subaccount
/