Re: Tree walking ordering at top of tree

From: David <dknight.work_at_googlemail.com>
Date: Tue, 1 Jul 2008 02:01:45 -0700 (PDT)
Message-ID: <6ae6f0b2-f9e1-483d-afb2-58d78b2c4d94@f36g2000hsa.googlegroups.com>


On Jun 30, 1:06 pm, Maxim Demenko <mdeme..._at_gmail.com> wrote:
> On 30 Jun., 11:32, David <dknight.w..._at_googlemail.com> wrote:
>
>
>
> > On Jun 28, 5:09 pm, Robert Klemme <shortcut..._at_googlemail.com> wrote:
>
> > > On 28.06.2008 01:45, Maxim Demenko wrote:
>
> > > > David schrieb:

<snip>
>
> > > I believe he wants to sort persons on the same hierarchy level by their
> > > names - something like this
>
> > > select e.id,lpad(e.name,length(e.name)+(level-1)*2,'-')
> > > from   employees e
> > > start with e.manager_id is null
> > > connect by prior e.id = e.manager_id
> > > order by level, name;
>
> > > Kind regards
>
> > >         robert
>
> > Hi
>
> > Thanks for the responses.  I'd better describe what I'm trying to
> > achieve, and what actually happens, using Robert's select:
>
> > > select e.id,e.manager_id,lpad(e.name,length(e.name)+(level-1)*2,'-')
> > > from   employees e
> > > start with e.manager_id is null
> > > connect by prior e.id = e.manager_id
> > > order by level, name;
>
> > Gives
>
> > ID      MANAGER_ID      LPAD(E.NAME,LENGTH(E.NAME)+(LEVEL-1)*2,'-')
> > 596             Smith
> > 7               Ince
> > 604             Clark
> > 606     604     --Dibble
> > 610     606     ----Cuthbert
> > 612     606     ----Grub
> > 614     612     ------Smith
> > 608     604     --Davidson
> > 85              Brown
> > 234             Jones
> > 568             Williams
> > 584             Gibson
> > 84      584     --Blake
> > 600     84      ----Donaldson
>
> > I'm aiming to get the top-level names in alphabetical order, but keep
> > the hierarchies intact:
>
> > ID      MANAGER_ID      LPAD(E.NAME,LENGTH(E.NAME)+(LEVEL-1)*2,'-')
> > 85              Brown
> > 604             Clark
> > 606     604     --Dibble
> > 610     606     ----Cuthbert
> > 612     606     ----Grub
> > 614     612     ------Smith
> > 608     604     --Davidson
> > 584             Gibson
> > 84      584     --Blake
> > 600     84      ----Donaldson
> > 7               Ince
> > 234             Jones
> > 596             Smith
> > 568             Williams
>
> > Regards
>
> > David
>
> Would  *order siblings by name* not suffice for your needs?
> Best regards
>
> Maxim

*order siblings by name* was exactly the answer I was looking for. Easy when you know how.

Thanks for your help everybody.

  • David
Received on Tue Jul 01 2008 - 04:01:45 CDT

Original text of this message