牛客网刷题之SQL-17.统计出当前各个title类型对应的员工当前薪水对应的平均工资

    科技2022-09-14  112

    统计出当前各个title类型对应的员工当前薪水对应的平均工资

    目录

    1. 题目

    2. 解题

    3. 知识点


    题目链接

    1. 题目

    2. 解题

    -- 写法一 select emp_no, salary from salaries s where s.to_date='9999-01-01' group by s.salary order by s.salary desc limit 1,1; -- 写法二 select emp_no, salary from salaries s where s.to_date='9999-01-01' and salary = ( select salary from salaries group by salary order by salary desc limit 1,1 ); -- 写法三 select emp_no, salary from salaries s where s.to_date='9999-01-01' and salary = ( select distinct salary from salaries order by salary desc limit 1,1 );

    3. 知识点

    ① limit 1, 1 筛选第二高德薪水 相关知识点可以查看这篇博客https://blog.csdn.net/zhqingyun163/article/details/5053579 ② distinct 和 group by 都可以起到去重的作用

    Processed: 0.008, SQL: 9