Top three restaurants in each city

MediumDoorDashranktop n per groupjoins· 20 XP

DoorDash's city managers each want their own "top 3 restaurants" list for a quarterly review.

Rank restaurants within their city by delivered revenue (order_total), highest first, and show the top 3 in each city. Use RANK(), so tied restaurants share a place.

Expected output

  • Any row order

Example of the shape (made-up values):

city restaurant_id revenue city_rank
Lakeside 41 2810.55 1

Hints, the later steps and the answer come with Pro.

Write your query here. Ctrl + Enter submits.