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!

Manager with no subordinates

Orcl ApexMay 11 2017 — edited May 11 2017

Hi All

I want to figure out all the managers who don't have any employee working under them.

There are many ways to do so but I want to achieve it with Model and MATCH_RECOGNIZE, please help in building it.

SELECT

    e.employee_id,

    e.first_name

FROM

    employees e

WHERE

    NOT EXISTS (

            SELECT employee_id

            FROM

                employees s

            WHERE s.manager_id   = e.employee_id);

                 

SELECT *

FROM employees

MODEL

DIMENSION BY (employee_id)

MEASURES (manager_id, first_name)

RULES

(

);

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 8 2017
Added on May 11 2017
6 comments
2,275 views