To find nth max salary using correlated query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * /*This is the outer query part */ | |
FROM Employee Emp1 | |
WHERE (N-1) = ( /* Subquery starts here */ | |
SELECT COUNT(DISTINCT(Emp2.Salary)) | |
FROM Employee Emp2 | |
WHERE Emp2.Salary > Emp1.Salary) |
No comments:
Post a Comment