Tree walking ordering at top of tree

From: David <dknight.work_at_googlemail.com>
Date: Fri, 27 Jun 2008 09:00:51 -0700 (PDT)
Message-ID: <24efab8e-1028-49b2-ab6c-f1389b874eed@z72g2000hsb.googlegroups.com>


Hi

I have the following query against the table create table employees (
  id number,
  manager_id number,
  name varchar2(100));

select e.id,lpad(e.name,length(e.name)+(level-1)*2,'-') from employees e
start with e.id in (select e2.id

                    from   employees e2
                    where  e2.manager_id is null
                    connect by prior e2.manager_id = e2.id)
connect by prior e.id = e.manager_id;

This returns a list of employees as a hierarchy, with the managers at the top and employees below, ordered as the hierarchy is structured.

However, not all employees have a manager, and there are several top level managers. I want to list the level 1 employees in alphabetical order, without affecting the display of the hierarchy levels where they exist beneath these.

Is this possible?

Many thanks

David Received on Fri Jun 27 2008 - 11:00:51 CDT

Original text of this message