sql实战_统计当前工资的排名情况

问题:已知存在一张工资表,请查询出每个员工的工号、工资、排名

解答:select s1.emp_no,s1.salary,(count(distinct s2.salary)) as rank

      from salaries as s1,salaries as s2

           where s1.to_date="9999-01-01"

           and s2.to_date="9999-01-01"

           and s1.salary<=s2.salary

    group by s1.emp_no

      order by s1.salary desc,s1.emp_no asc

posted @ 2019-07-16 10:15  helloworldmybokeyuan  阅读(457)  评论(0编辑  收藏  举报