Mysql
 sql >> Datenbank >  >> RDS >> Mysql

So finden Sie das zweithöchste Gehalt in mysql

Versuchen Sie Folgendes:

SELECT emp_name,salary 
FROM Employee
WHERE salary = (SELECT DISTINCT salary FROM Employee as emp1
                WHERE (SELECT COUNT(DISTINCT salary)=2 FROM Employee as emp2
                WHERE emp1.salary <= emp2.salary)) 
ORDER BY emp_name