Top-N per Group
Learn Top-N per Group (Window Functions, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Introduction "Top-N per group" (best 3 products in each category, latest order per customer) is the most common window-function interview and production pattern: rank rows inside each partition with ROW_NUMBER / RANK / DENSE_RANK , then filter on the rank in an outer query or CTE.