Discussion about this post

User's avatar
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
Ehi Eromosele's avatar

Awesome article. Is there a version for Python interviews?

For instance, is there methods to review in Data Structures and Algorithms?

Expand full comment
13 more comments...