Mockbit/#54
SQLeasyRanking~12m

QuickBite food delivery wants to identify the top 3 performing restaurants in...

Problem

QuickBite food delivery wants to identify the top 3 performing restaurants in each city based on their average delivery rating. Include all restaurants that achieve a top-3 ranking, even if there are ties. Return the restaurant name, city, average rating (rounded to 2 decimal places), and their ranking within the city.

Examples

Example 1

Example 2

Constraints
  • Return restaurant_name, city, avg_rating (rounded to 2 decimals), city_rank
  • Only include restaurants ranked 1-3 within their city
  • Handle NULL ratings by excluding them from average calculation
  • Break ties by restaurant_id (ascending)
Reference solution

Reference solution available after you attempt the question.

Ready to solve it?

Start a session on Mockbit #54. Write your SQL, run it against real data, and get graded on correctness, efficiency, query structure, and business understanding.

Related SQL questions
← Back homemockbit.io/q/54
PrivacyTerms© 2026 Mockbit