Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> question on hierarchical query
hi,
I'm having trouble constructing a hierarchical query.
Can someone help.
SQL> select * from hier;
A B
---------- ----------
99 7 100 1 100 2 1 2 2 3 4 8 200 6
7 rows selected.
The order of the output is not important. The output can be:
100 1 1 2 2 3 100 2 2 3 -> should not display this duplicate 200 6
OR
100 1 100 2 1 2 2 3 2 3 -> should not display this duplicate 200 6
We will start with a number. In this case, 100. If
a=100, get the corresponding value of b and match that
back to a and get the next corresponding value of b
until b!=a. After the first iteration, now get the
next value of a>=100 and process it in the same
manner.
Duplicate records should only be displayed once, in
this case, 2 3 should only be displayed once.
Is it possible to achieve the requirements in a single query?
thanks.
susan
--
http://www.freelists.org/webpage/oracle-l
Received on Fri Oct 15 2004 - 07:25:00 CDT
![]() |
![]() |