Here is the SQL Query:
SELECT * FROM emptable e1 WHERE (N = (SELECT COUNT(DISTINCT (e2.empsalary))
FROM emptable e2 WHERE e2.empsalary >= e1.empsalary))
Note: you need to replace the value of N while running the query.
Example:
If you want highest paid employee details then value of N=1 then query will look like :
SELECT * FROM emptable e1 WHERE (1 = (SELECT COUNT(DISTINCT (e2.empsalary))
FROM emptable e2 WHERE e2.empsalary >= e1.empsalary))
No comments:
Post a Comment