Reputation: 13
how to write SQL to display How many employees doesn't belong to any department?
Upvotes: 0
Views: 1696
Reputation: 1271091
How about this?
select count(*)
from employees
where deptno is null;
Upvotes: 1
Reputation: 222682
That's basic filtering:
select count(*) cnt
from employees
where depno is null
That gives you the count of employees that are not assigned to a department. If you want to list the corresponding rows:
select *
from employees
where depno is null
Upvotes: 0