I want to write this query in SQL Server
from ( select DISTINCT salary from employee order by salary desc ) where rownum = 3;
See ROW_NUMBER () :
For instance,
WITH EmployeeSalary AS ( select salary, ROW_NUMBER() OVER (order by salary desc) AS 'RowNumber' FROM employee group by salary --you can't use DISTINCT because ROW_NUMBER() makes each row distinct ) SELECT * FROM EmployeeSalary WHERE RowNumber = 3;
SELECT DISTINCT salary FROM employee WHERE rownum = 3 ORDER BY salary
Covers are optional. Is rownum a column in an employee, or are you only looking for a third row?