#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Hierarchical queries?


    Any idea how to count siblings in a hierarchical query? I'm trying to get a listing of employees

    SELECT LEVEL, last_name||', '||first_name AS Manager, count(employee_id)
    FROM employees
    START WITH manager_id IS NULL
    CONNECT BY PRIOR employee_id = manager_id
    GROUP BY level

    This returns 4 levels. I'm wanting to add up the number of siblings under the level 2 instead of listing them all. But, I'm getting stuck.
  2. #2
  3. Humble Learner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    280
    Rep Power
    120
    You need to either remove the following fields from the select part or add the same into the group by clause after level.

    last_name||', '||first_name AS Manager

IMN logo majestic logo threadwatch logo seochat tools logo