1789.sql (181B)
1 SELECT employee_id, department_id 2 FROM Employee 3 GROUP BY employee_id 4 HAVING COUNT(department_id) = 1 5 UNION 6 SELECT employee_id, department_id 7 FROM Employee 8 WHERE primary_flag = 'Y'