Editorial / Best Answer
Answered by:
Yadnesh
-- First of all Customers table wont have salary attribute. we need to use employees/employeesSalary table
-- where we can find salary attribute.
-- for finding nth lowest salary record we can obtain derived column using DENSE_RANK() in a subquery and
-- obtain temporary result set and finding nth record in a temporary result set using WHERE clause
-- for the given example, following is the solution.
Code
SELECT x.rate
,x.rankedSalary
FROM (SELECT rate
,DENSE_RANK() OVER (ORDER BY rate) AS rankedSalary
FROM HumanResources.EmployeePayHistory
GROUP BY rate) x
WHERE x.rankedSalary = 4
SQL Query
Questions by rohitdeepu17
Editorial / Best Answer
Answered by: Yadnesh
-- First of all Customers table wont have salary attribute. we need to use employees/employeesSalary table -- where we can find salary attribute. -- for finding nth lowest salary record we can obtain derived column using DENSE_RANK() in a subquery and -- obtain temporary result set and finding nth record in a temporary result set using WHERE clause -- for the given example, following is the solution.
Related Answered Questions
Related Open Questions