← All SQL interview questions

Restaurants with consistently high ratings

MediumHAVINGZomatoSwiggy

The partnerships team wants to feature restaurants that have enough order volume and a strong average rating. Some customers skip the rating prompt, so rating can be NULL.

From restaurant_orders, return restaurant_name, total_orders, rated_orders (orders that have a rating) and avg_rating (rounded to 2 decimals) for restaurants with at least 3 orders and an average rating of 4.2 or higher. Order by avg_rating descending, then restaurant_name.

Sample data

Table: restaurant_orders

18 row(s) · showing first 8

order_idINTrestaurant_nameTEXTcityTEXTorder_valueNUMERIC(8,2)ratingINT
1Spice RouteDelhi640.005
2Spice RouteDelhi820.004
3Spice RouteDelhi560.005
4Spice RouteDelhi710.00NULL
5Dosa JunctionBengaluru280.004
6Dosa JunctionBengaluru310.004
7Dosa JunctionBengaluru350.005
8Dosa JunctionBengaluru260.004