Re: Help needed in SQL Query for Hierarchy

From: Russ Bagley <bigfatface_at_hotmail.com>
Date: 15 Sep 2003 07:06:21 -0700
Message-ID: <b863dacd.0309150606.46558f1f_at_posting.google.com>


Try:

select level

,a.emplid
,a.emp_pos
,a.flag
,a.boss_pos
from temp a
where a.date = (select max(c.date)

                 from   temp c
                 where  c.emplid = a.emplid)
and flag = 'Y'
connect by prior boss_pos=emp_pos
start with emplid = 'z001'

It works with the data you supplied (on a 9i database). I don't know if this is the most efficient way (sub-selects are always pretty slow). Received on Mon Sep 15 2003 - 16:06:21 CEST

Original text of this message