question on hierarchical query

  • From: susan lam <susanzlam@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Fri, 15 Oct 2004 05:29:32 -0700 (PDT)

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


                

--
//www.freelists.org/webpage/oracle-l

Other related posts: