Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Removing duplicate subtrees from CONNECT-BY query
Riku Räsänen schrieb:
Depends on the criteria, which subtrees you like to retain. For example,
if you wish to reject all except under the first parent_id (first in
sense of ordered by parent_id), you could do something like
SELECT LPAD (' ', (LEVEL - 1) * 2) || TO_CHAR (id, '999') id
, parent_id
FROM (select id,min(parent_id) parent_id from tree_hierarchy group by id)
START WITH id = 1
CONNECT BY PRIOR id = parent_id
Best regards
Maxim
-- http://www.freelists.org/webpage/oracle-lReceived on Sun Oct 07 2007 - 14:54:39 CDT
![]() |
![]() |