0

I would like to ask you to help me to find top level id from multilevel structure.

my code is:

SELECT level,id_component, CONNECT_BY_ROOT id_part
  FROM structure
   START WITH id_component = '123'
CONNECT BY PRIOR id_part = id_component

this give me result like:

level id_component id_part
----- ------------ -------
1         123        770
2         770        771
3         771        778
3         771        880

but I need only two id_part from level 3 (778 and 880)

many thanks

denn
  • 137
  • 1
  • 5
  • 14
  • There is no way the query you posted gives you the result you posted. You start with `id_component = '123456'`, I don't see that in the output. Also, the query includes `SYS_CONNECT_BY_PATH` in the `SELECT` clause - where is that column in the output? How can we take you seriously? –  Jan 30 '18 at 20:04
  • Hello, sorry for the mistake, I have changed. – denn Jan 30 '18 at 20:13
  • 1
    did you notice the Answer already posted? Is that what you need? –  Jan 30 '18 at 20:25

1 Answers1

2

Add

where connect_by_isleaf = 1

right after the FROM clause and before CONNECT BY.