Skip to content
ML Academy

SQL and Python

Interview question

  • midlevel
  • 6 minsuggested time
  • 2Data analyst, Data scientist

For each route, return the three highest-revenue flight-days. Two flight-days on a route can have identical revenue. Write the query and explain how ROW_NUMBER, RANK and DENSE_RANK would change the result.

Tests: Top-N per group with ranking window functions, tie handling, and why window results must be filtered in an outer query.

Sign in to practise: answers are saved before model answers are shown.