10. Monthly Product Rating

Easy

reviews(review_id, product_id, stars, created_at)

For every product and month of 2026, return the average star rating rounded to two decimals and how many reviews it came from.

Return month as a 'YYYY-MM' string, plus product_id, avg_rating and review_count, ordered by month then product.

Only months a product actually has reviews in appear. No gaps are filled.

Tables

reviews

review_id  product_id  stars  created_at
---------  ----------  -----  ----------
1          100         5      2026-01-05
2          100         4      2026-01-20
3          100         1      2026-01-28
4          100         3      2026-02-02
5          200         2      2026-01-11
6          100         5      2025-12-31

Expected result

month    product_id  avg_rating  review_count
-------  ----------  ----------  ------------
2026-01  100         3.33        3
2026-01  200         2.00        1
2026-02  100         3.00        1

Sign in to write and run your own code.

Write one SELECT query