sql server - Can somebody explain how the following SQL query to get the 'n' highest salary works -


Select a worker WHERE 3 = (select count (*) from 1 employee, where B sealery> A salary)

This receives the 3 highest wages; Someone can explain the reasoning behind this query and how it works.

In the words, this query "Select the employee who has two more salaries." Therefore, the result is the third highest-paid employee.

Note that if two or more people are meeting with the same salary then this query may fail.


Comments