Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle Hierarchical Query + Parent records without children records

450bbb62-447d-4a75-aa9f-b669a5629adfMar 26 2018 — edited Mar 27 2018

Hello everyone!

I have a question in the query below. I need you to return the records of parents who have child records attached to them. Records do not have children, they should not appear. How to proceed?

Example:

SELECT TB1.FIELD_SUP,  TB1.NUMBER

FROM TABLE1 TB1 

START WITH TB1.FIELD3        = '999999' 

CONNECT BY NOCYCLE TB1.FIELD_SUP = PRIOR TB1.NUMBER

AND TB1.FIELD4 IN (SELECT TB2.FIELD1   FROM TABLE2 TB2   WHERE TB2.FIELD2 IN ('123456','789123')   )

ORDER SIBLINGS BY TB1.NUMBER,   TB1.FIELD4;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2018
Added on Mar 26 2018
17 comments
1,274 views