题解 | 查找所有员工的last、first、dept
查找所有员工的last_name和first_name以及对应的dept_name
https://www.nowcoder.com/practice/5a7975fabe1146329cee4f670c27ad55
with pt_pa as( select emp_no, dept_name from dept_emp pt join departments pa on pt.dept_no = pa.dept_no ) select last_name,first_name,dept_name from pt_pa right join employees pl on pt_pa.emp_no = pl.emp_no;
要注意:dept_emp表里是已分配部门的员工,employees才是所有员工