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

Home -> Community -> Mailing Lists -> Oracle-L -> help for SQL query ... start with connect by ....

help for SQL query ... start with connect by ....

From: Kumar, Dharminder <Dharminder.Kumar_at_bmonesbittburns.com>
Date: Fri, 02 Mar 2001 11:24:59 -0800
Message-ID: <F001.002C2A88.20010302112325@fatcity.com>

SQL> desc tbl_mgr

 Name                                      Null?    Type
 ----------------------------------------- --------
----------------------------
 MANAGER                                            VARCHAR2(30)
 PROFILEID                                          NUMBER(3)
 PARENTID                                           NUMBER(3)

I am running the following query on the table.

select rpad(' ',level*20,' ')||Manager manager1,parentid,profileid  from tbl_mgr
start with parentid = 0
connect by prior profileid= parentid ;

and get the following result.

                                                            
MANAGER1                        PARENTID        PROFILEID
   MSS                  0               1       
      Bursh                     1               2
         O Donnell      2               617
         Bursh Own      2               618
         Aursh Own      2               619
      Stredde           1               3
........................
........................

Now my requirement is that I want the output to be like mentioned bellow.

MANAGER1                        PARENTID        PROFILEID
   MSS                  0               1       
      Bursh                     1               2
         Aursh Own      2               619
         Bursh Own      2               618
         O Donnell      2               617

      Stredde           1               3

I mean that for level three managers the output should be sorted by manager name.
And I want this to be accomplished by a SQL query only..

Thanks.

Dharminder Kumar

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Kumar, Dharminder
  INET: Dharminder.Kumar_at_bmonesbittburns.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Mar 02 2001 - 13:24:59 CST

Original text of this message

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