Write a query in SQL to list the department where there are no employees
- 2021-09-08
- mhanasmh00489829403
- م97
الأجوبة
SELECT b.dep_id,
count(a.dep_id)
FROM department b
LEFT OUTER JOIN employees a ON a.dep_id=b.dep_id
GROUP BY b.dep_id
HAVING count(a.dep_id) = 0;
Sample Output:
dep_id | count --------+------- 4001 | 0 (1 row)