赞
踩
- select id,month,salary+ifnull(l1,0)+ifnull(l2,0) salary
- from
- (select *,lag(salary,1) over(partition by id order by month ) l1,
- lag(salary,2) over(partition by id order by month)l2,
- rank() over(partition by id order by month desc) r
- from employee)A
- where r>1
- order by 1,2 desc;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。