2 Comments
User's avatar
⭠ Return to thread
glo's avatar

I've been asked to solve a "n-th highest salary" problem without using a WINDOW function.

Solution:

1) a first CTE with ordered salaries in descending order limit to n row. (e.g. if it's the 3rd highest salaries then LIMIT 3)

2) Another CTE reversing the order of the above one limited to the first row. (LIMIT 1)

note: it only works if there are no rows with duplicated salaries

note2: LIMIT and OFFSET weren't allowed

Expand full comment
Adi's avatar

If LIMIT is not allowed in steps 1 and 2, you have used LIMIT. Is this something wrong in my understanding

Expand full comment