Lesson 9.3 · Pro
Top N per group and latest row per group
Rank inside each group in a CTE, then keep rank 1 (or the top few) in the next step.
In this lesson
- Rank in a CTE, filter after
- Top N, keeping ties
- The lowest row works the same way
Go Pro to read this lesson
Pro unlocks every lesson and practice problem in SQL, Python, pandas and NumPy, with answers and step-by-step explanations.