Company: Airbnb | Difficulty: medium
Airbnb's quality team wants to identify products with consistently low review ratings.
Find every product whose average review rating is strictly less than 4.0. Ignore reviews with missing ratings when calculating the average.
Return the product ID and its average rating rounded to two decimal places. Sort the results by product ID in descending order.
Product 5002 has an average rating of 3.00, which is strictly below 4.0, so it is returned. Product 5001 averages 4.50 and product 5003 averages 4.75, so both are excluded.
DROP TABLE IF EXISTS reviews; CREATE TABLE reviews ( review_id INT, product_id INT, rating DECIMAL(3,1) ); INSERT INTO reviews VALUES (1, 5001, 5.0), (2, 5001, 4.0), (3, 5002, 3.0), (4, 5002, 3.0), (5, 5003, 4.5), (6, 5003, 5.0);
← All SQL Challenges · Airbnb Questions · Learn SQL Free