0
create table employee
    (emp_id     integer     not null,
     manager_id     integer     not null,   
     emp_name   char(20)    not null,
     emp_tel    char(10),
     emp_salary number      not null,
     hire_date  date,
    constraint pk_employee primary key(emp_id)
    );

alter table employee 
add constraint fk_employee_manager foreign key(manager_id) 
references employee(emp_id);

Need help to Find the ID of managers that have more than 5 employees working with them.

0

2 Answers 2

1

just do this: You need to familialrize yourself with the possibilities of grouping functions

select manager_id     
from employee
group by manager_id     
having count(*)>5
Sign up to request clarification or add additional context in comments.

1 Comment

The Code is correct , but its giving me no such result.
0
insert into employee (emp_id, manager_id, emp_name, emp_salary)
select 1, 1, 'A', 1000 from dual
union select 2, 1, 'A', 1000 from dual
union select 3, 1, 'A', 1000 from dual
union select 4, 1, 'A', 1000 from dual
union select 5, 1, 'A', 1000 from dual
union select 6, 1, 'A', 1000 from dual
union select 7, 2, 'A', 1000 from dual;

select manager_id, count(emp_id) from employee group by manager_id
having count(emp_id) > 5;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.