Advertisement
dragonbs

Find All Employees with Rank 2

Sep 25th, 2023
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.26 KB | None | 0 0
  1. SELECT * FROM (SELECT [EmployeeID], [FirstName], [LastName], [Salary],
  2. DENSE_RANK() OVER (PARTITION BY [Salary] ORDER BY [EmployeeID]) AS [Rank]
  3. FROM [Employees]
  4. WHERE [Salary] BETWEEN 10000 AND 50000 ) AS [query]
  5. WHERE [query].[Rank] = 2
  6. ORDER BY [Salary] DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement