Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> question on hierarchical query

question on hierarchical query

From: susan lam <susanzlam_at_yahoo.com>
Date: Fri, 15 Oct 2004 05:29:32 -0700 (PDT)
Message-ID: <20041015122932.61838.qmail@web53306.mail.yahoo.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US