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

Home -> Community -> Usenet -> c.d.o.server -> How to Query Part of Hierarchical Tree List

How to Query Part of Hierarchical Tree List

From: Allen <allen_at_ms15.hinet.net>
Date: Thu, 7 Oct 1999 19:53:17 +0800
Message-ID: <7ti1t7$sbe@netnews.hinet.net>


Hi, All:
  Need your help:
  I created a table
    TTT (parent varchar2(100), child varchar2(100), flag varchar2(1));     insert some data:

        parent   child   flag
         A          B        Y
         A          C        Y
         A          D        N
         B          B1       N
         B          B2       Y
         B          B3       N
         B2        B21     N
         B2        B22     Y
         B2        B23     N
         C          C1       Y
         C          C2       N

Q1: How can I get the count (flag='Y') that in every hierachical tree list like that (in a Single Sql Statement):
       parent   child    flag    count
         A          B        Y        1      (A-B)=(Y)
         A          C        Y        1      (A-C)= (Y)
         A          D        N        0      (A-D)= (N)
         B          B1       N        1      (A-B, B-B1)=(Y,N)
         B          B2       Y        2      (A-B, B-B2)=(Y,Y)
         B          B3       N        1      (A-B, B-B3)=(Y,N)
         B2        B21     N        2      (A-B, B-B2, B2-B21)= (Y,Y)
         B2        B22     Y        3      (A-B, B-B2, B2-B22)= (Y,Y,Y)
         B2        B23     N        2      (A-B, B-B2, B2-B23)= (Y,Y,N)
         C          C1       Y        2      (A-C, C-C1)             = (Y,Y)
         C          C2       N        1      (A-C, C-C2)             = (Y,N)
Q2:
      How can I get a tree list using a Single SQL to get tree listing start
with 'A' and end with 'B22'
  like that :
              A    B
              B    B2
              B2  B22


Best Regards,
Allen Received on Thu Oct 07 1999 - 06:53:17 CDT

Original text of this message

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