D Cube Analytics Interview Question | CTE

Question

How can you use a CTE to return the fifth highest (or Nth highest) salary from a table?

in progress 0
Dhruv2301 55 years 2 Answers 2003 views Great Grand Master 0

Answers ( 2 )

  1. WITH find5thHighest AS (
    SELECT
    *,
    RANK() OVER (ORDER BY salary DESC) as rnk
    FROM table
    )
    SELECT * FROM find5thHighest
    WHERE rnk = 5

Leave an answer

Browse
Browse