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
- #41You're analyzing user engagement for a social media platformeasy
- #43A regional bank wants to analyze account activity by branch locationeasy
- #44A medical clinic wants to identify patients who have been prescribed medications...easy
- #42A video streaming platform tracks user viewing sessionshard
- #45A mobile gaming company wants to identify the top 3 most active players for each...easy
← Back homemockbit.io/q/54