delete from departments d where not exists (select * from employees where departmentid = d.departmentid)