Hi all,
I hope I'm able to explain the problem that is puzzeling me. I have the following hierarchical data set (this is just subset of 34K records)
PARENT_ID CHILD_ID EXAM
TUDA12802 TUDA12982 N
TUDA12982 TUDA12984 J
TUDA12984 TUDA999 J
TUDA12982 TUDA12983 N
TUDA12983 TUDA15322 J
TUDA12983 TUDA15323 J
This is a representation of the tree
TUDA12982 N
- TUDA12984 J
-- TUDA999 J
- TUDA12983 N
-- TUDA15322 J
-- TUDA15323 J
What I need is a list of all records with exam=N and the underlying exam = 'J' records, which can be nested.
select *
from test1
connect by prior child_id = parent_id
start with child_id = 'TUDA12982'
order siblings by child_id;
Gives me
PARENT_ID CHILD_ID EXAM
TUDA12802 TUDA12982 N
TUDA12982 TUDA12984 J
TUDA12984 TUDA999 J
TUDA12982 TUDA12983 N
TUDA12983 TUDA15323 J
TUDA12983 TUDA15322 J
But what I need is
TUDA12802 TUDA12982 N
TUDA12982 TUDA12984 J
TUDA12984 TUDA999 J
The traversing needs to stop when I encounter a EXAM = 'N' record.
I need something like a 'stop with' clause.
select *
from test1
connect by prior child_id = parent_id
start with child_id = 'TUDA12982'
stop with exam = 'N'
order siblings by child_id;
How can this be done?