1 对所有员工的当前(to_date='9999-01-01')薪水按照salary进行按照1-N的排名,相同salary并列且按照emp_no升序排列
连接一张大表,比A的salary大的个数,就是这个员工收入的排名
select a.emp_no,a.salary,
count(distinct b.salary) as t_rank
from salaries as a,salaries as b
where a.salary<=b.salary
and a.to_date='9999-01-01'
and b.to_date='9999-01-01'
group by a.emp_no
ORDER BY t_rank
a<=b 要考虑到最后一名如果不带等号就被舍去了
分组应该按no号分组,如果按a.salary分组就会导致收入相同的忽略掉