题解 | 更新员工信息表
更新员工信息表
https://www.nowcoder.com/practice/1eb20d4bf7c5443da7b84105372c9070
with a as ( select * from EMPLOYEE_INFO union all select EMPLOYEE_ID,NEW_POSITION,UPDATE_DT from EMPLOYEE_UPDATE ) select c.EMPLOYEE_ID, c.POSITION, c.LAST_UPDATE_DT from ( select a.EMPLOYEE_ID, a.POSITION, a.LAST_UPDATE_DT, row_number() over(partition by a.EMPLOYEE_ID order by LAST_UPDATE_DT desc) as last_date from a ) as c where c.last_date=1 order by c.EMPLOYEE_ID