1
hustlike 2017-06-21 21:59:16 +08:00
降过多次怎么算
|
2
lusheldon OP @hustlike 降多次的情况下,应该也是可以查的吧。咱们先假设每个人最多可能降薪一次吧。
|
3
reus 2017-06-21 22:06:59 +08:00 1
select
distinct emp_no from salaries a join salaries b on a.emp_no = b.emp_no and a.to_date > b.to_date and a.salary < b.salary |
8
lusheldon OP select a.emp_no,b.salary-a.salary, a.to_date
from salaries a join salaries b on a.emp_no=b.emp_no and a.to_date>b.to_date and a.salary<b.salary and a.from_date=b.to_date; 奉上完整答案,再次感谢 @reus |
9
wwww961h 2017-06-21 22:29:23 +08:00
用 join,把一个表当两个表用,特别简单
|
10
sohucw 2017-06-22 09:20:19 +08:00
select a.emp_no,b.salary-a.salary, a.to_date
from salaries a join salaries b on a.emp_no=b.emp_no and a.to_date>b.to_date and a.salary<b.salary and a.from_date=b.to_date; 正解啊 |