Problems / Top Category per Region (No Windows) / Editorial
region_category
SUM(revenue) GROUP BY region, category
region_max
MAX(total_revenue) GROUP BY region
region_category JOIN region_max ON same region AND total_revenue = max_revenue
Groupby-max plus join-back is the classic argmax idiom from before window functions existed, and it is still worth knowing: it is the natural shape in engines and tools without windows, and its tie behavior is explicit — the equality join keeps all argmax rows, whereas ROW_NUMBER() = 1 would silently pick a single winner. (RANK() = 1 matches this query's semantics; comparing the two is a good self-check.)
ROW_NUMBER() = 1
RANK() = 1
Solve Top Category per Region (No Windows) yourself →