#20

Average product rating by month

Amazon is analyzing month-by-month changes in product ratings. For each month and product_id pair, calculate the average product rating. Round it to two decimal places and return it in the avg_stars column. Also return mth — the month number — and product_id. Sort the result by mth, then by product_id.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.

mthavg_starsproduct_id
13.50101
14.00103
24.00101
Amazon

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid