Judy
Judy

Reputation: 13

how to display employee that doesn't belong to department (SQL)

how to write SQL to display How many employees doesn't belong to any department? enter image description here

Upvotes: 0

Views: 1696

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1271091

How about this?

select count(*)
from employees
where deptno is null;

Upvotes: 1

GMB
GMB

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

Related Questions