Hierarchy problem [message #626430] |
Mon, 27 October 2014 15:23 |
Amine
Messages: 375 Registered: March 2010
|
Senior Member |
|
|
Hi all,
I have this table
create table f_user_rat
(
typ_hierarchy number(5) ,
pere number(5) ,
fils number(5)
)
;
insert into f_user_rat values (10, null,1);
insert into f_user_rat values (10, null,6);
insert into f_user_rat values (10, 1,6);
insert into f_user_rat values (10, 1,2);
insert into f_user_rat values (10, 1,3);
insert into f_user_rat values (10, 1,4);
insert into f_user_rat values (10, 1,5);
insert into f_user_rat values (10, 6,2);
insert into f_user_rat values (10, 6,3);
insert into f_user_rat values (10, 6,4);
insert into f_user_rat values (10, 6,5);
Then I run this query :
column typ_hierarchy format 999
column label format a20
select typ_hierarchy, rpad('-', 3 * level, '-') || fils label
from f_user_rat
where 1 = 1
connect by prior fils = pere and prior typ_hierarchy = typ_hierarchy
start with pere is null
order siblings by typ_hierarchy
/
The result is :
10 ---1
10 ------2
10 ------3
10 ------4
10 ------5
10 ------6
10 ---------2
10 ---------3
10 ---------4
10 ---------5
10 ---6
10 ------2
10 ------3
10 ------4
10 ------5
15 rows selected.
SQL>
I want this result :
10 ---1
10 ------2
10 ------3
10 ------4
10 ------5
10 ------6
10 ---------2
10 ---------3
10 ---------4
10 ---------5
10 rows selected.
Meaning I want to exclude the repetition. Is that possible ?
Thanks in advance,
Amine
|
|
|
|
|
|
|
|
Re: Hierarchy problem [message #626754 is a reply to message #626750] |
Sun, 02 November 2014 01:22 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Michel Cadot wrote on Mon, 27 October 2014 21:46How
is a "repetition" of
?
Quote:Meaning I want to exclude the repetition. Is that possible ?
What about DISTINCT?
If you don't care about the numbers of '-' then leave them.
|
|
|