l两个salary子查询相减
给出每个员工每年薪水涨幅超过5000的员工编号emp_no
http://www.nowcoder.com/questionTerminal/eb9b13e5257744db8265aa73de04fd44
select s1.emp_no,s2.from_date,
(s2.salary-s1.salary)as salary_growth
from
(
select s.emp_no,s.salary,s.from_date,strftime('%Y', from_date) as from_d
from salaries s
) s1
join
(
select s.emp_no,s.salary,s.from_date,strftime('%Y', to_date) as to_d
from salaries s
) s2
on s1.emp_no =s2.emp_no and s2.to_d-s1.from_d=2
and (s2.salary-s1.salary)>5000
order by salary_growth desc