题解 | 开窗函数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