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

3
  • 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? Commented Jan 30, 2018 at 20:04
  • Hello, sorry for the mistake, I have changed. Commented Jan 30, 2018 at 20:13
  • 1
    did you notice the Answer already posted? Is that what you need? Commented Jan 30, 2018 at 20:25

1 Answer 1

2

Add

where connect_by_isleaf = 1

right after the FROM clause and before CONNECT BY.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.