Average product rating by month

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. Your answer must use the same column names as this sample — alias them with AS if needed.

mthproduct_idavg_stars
11013.50
11034.00
21014.00
Amazon

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid