Skip to content
Theory · Window functions · lesson 8 of 12

Top N in each group

The display needs the two most expensive items in each category. This is one of the most common SQL interview tasks.

In this lesson

  • Number first, then pick
  • The same technique with WITH
  • Which function to choose
  • Common mistake
  • Key points