Problem: 1789. 员工的直属部门 👨🏫 参考题解 Code select employee_id, department_id from Employee where primary_flag = 'Y' # Y 表明是直属部门 or employee_id in ( select employee_id from Employee group by employee_id having count(employee_id) = 1 # 子查询的结果是 单一部门的员工id集 )