题解 | 更新员工信息表

更新员工信息表

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

  

全部评论

相关推荐

05-09 14:45
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务