Hierarchical queries?
964010Sep 24 2012 — edited Sep 24 2012I'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?