分析:
1.计算薪水涨幅必须知道涨薪前的薪水和涨薪后的薪水,故需要两个表,这两个表可以通过复用salaries实现
2.每年 可以是涨薪后的to_date - 涨薪前的to_date = 1或者
涨薪后的from_date - 涨薪前的from_date = 1或者
代码:
select s2.emp_no,s2.from_date,(s2.salary - s1.salary) as salary_growth
from salaries as s1,salaries as s2
where s1.emp_no = s2.emp_no
and (strftime(’%Y’,s2.to_date) - strftime(’%Y’,s1.to_date) = 1
or strftime(’%Y’,s2.from_date) - strftime(’%Y’,s1.from_date) = 1)
and s2.salary - s1.salary > 5000
order by salary_growth desc