Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Hierarchical queries?

964010Sep 24 2012 — edited Sep 24 2012
I'm having trouble trying to get a hierarchical query to output correctly. How can I count the number of leafs under someone? For instance, if the query is:


SELECT LEVEL, last_name||', '||first_name AS Manager, COUNT(id)
FROM emp
START WITH manager_id IS NULL
CONNECT BY PRIOR id = manager_id
GROUP BY level;

but I only want to return the first two levels with the number of people working under them?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 22 2012
Added on Sep 24 2012
3 comments
250 views