Chapter 5 · JOINs
17. Products with Average Rating and Review Count
Medium20 XPE-Commerce
Create a product report showing each product's name, price, number of reviews, and average rating. Include products with zero reviews (show 0 for count and NULL for average). Sort by average rating descending, with NULLs last.
Tables
- PKidINT
- nameTEXT
- FKcategory_id→ categories.idINT
- priceREAL
- costREAL
- stock_quantityINT
- created_atTIMESTAMP
- PKidINT
- FKproduct_id→ products.idINT
- FKcustomer_id→ customers.idINT
- ratingINT
- commentTEXT
- review_dateTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.