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

Home -> Community -> Usenet -> c.d.o.misc -> Sorting hierarchical query

Sorting hierarchical query

From: Oren Nakdimon <oren_at_gsit.co.il>
Date: 1997/11/08
Message-ID: <34644B81.D770571C@gsit.co.il>#1/1

Hi.
Consider the employees table, where each record contains the id number and the name of an
employee, and, in addition, the id number of the employee's manager:

  create table EMP (
    EMPNO number(4),
    ENAME varchar2(100),
    MGR number(4) );

I select the employees' tree by:

  select EMPNO,ENAME
  from EMP
  connect by prior EMPNO = MGR;

(never mind the tree-shape displaying now).

Now, I need to improve this query so all the employees with the same manager will be ordered by
ENAME.
Does anyone has an idea how to do that ?
(The SELECT must be in SQL. However, using PL/SQL functions within the
query is allowed).

Thanks.

--
====================================================
Oren Nakdimon
Golden Screens Ltd.
address: 17 Abba-Hillel st., Ramat-Gan 52522, ISRAEL
email:   oren_at_gsit.co.il
tel:     +972-3-7510836
fax:     +972-3-7518221
====================================================
Received on Sat Nov 08 1997 - 00:00:00 CST

Original text of this message

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