| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: yet another hierarchy model
I got a little time to play with this model and my nested sets. I
have a few versions of views for the Immediate_subordinates(boss,
worker, lft, rgt), since it seems to be a frequent query. I can get
the level and the sibling position in a nested set table with this.
SELECT T2.emp, COUNT(T1.lft) AS level
FROM Personnel AS T1, Personnel AS T2
WHERE T2.lft BETWEEN T1.lft AND T1.rgt
GROUP BY T2.emp;
I think this query can be made better.
SELECT P1.emp AS boss, S1.worker,
COUNT(S2.lft) AS sibling_order
FROM Immediate_subordinates AS S1,
Immediate_subordinates AS S2,
Personnel AS P1
WHERE S1.boss = P1.emp
![]() |
![]() |