题解 | 开窗函数yyds

获取每个部门中当前员工薪水最高的相关信息

https://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6

with temp as(select 
    s.emp_no a,
    dept_no b,
    s.from_date,
    salary,
    max(salary) over(partition by dept_no order by s.from_date rows between unbounded preceding and unbounded following) c
from dept_emp d join salaries s on d.emp_no = s.emp_no)
select b,a,salary
from temp where salary = c

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务