ps: hab noch meinen Versuch dazugestellt, ich arbeite allerdings mit der Originaltabelle, welche nicht ganz dem Schema entspricht, aber die Logik sollte ja gleich sein:
Code:
SQL> select * from stat_produkt;
ID PRODUKT_ID EINHEIT_ID CODE BEZEICHNUNG
---------- ---------- ---------- -------------------- ----------------
26 24 p21 produkt21
23 17 p1 Produkt1
24 p2 produkt2
25 23 19 p11 produkt11
27 24 18 p22 Produkt22
SQL>
SQL> column padded_bez format a20
SQL>
SQL> Select lpad(' ',(level-1)*2) || Bezeichnung as padded_bez
2 , ID , Produkt_ID, Einheit_ID, level
3 from stat_produkt connect by prior Id=Produkt_id;
PADDED_BEZ ID PRODUKT_ID EINHEIT_ID LEVEL
-------------------- ---------- ---------- ---------- ----------
produkt11 25 23 19 1
produkt21 26 24 1
Produkt22 27 24 18 1
Produkt1 23 17 1
produkt11 25 23 19 2
produkt2 24 1
produkt21 26 24 2
Produkt22 27 24 18 2
8 Zeilen ausgewählt.
Was mich stört, ist dass ich diese roten Unterprodukte auch oben nocheinmal dabeihabe :/