我知道这个查询,但它是子查询,谁能解释一下我在面试中问过这个问题的困惑,但我无法正确解释
select * from dept e where 2 =(select count(distinct salary) from dept where e.salary<=salary)
最佳答案
尝试这个非常简单:
SELECT id, dept_name, DISTINCT salary FROM dept_table DESC salary LIMIT 2 OFFSET 2
关于mysql - 如何在不使用子查询的情况下在mysql中找到第二和第三高的工资,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39091946/