SELECT
DATE_TRUNC('month', submit_date) AS mth,
p.product_name AS product,
ROUND(AVG(stars), 2) AS avg_stars
FROM reviews r
JOIN products p ON p.product_id = r.product_id
GROUP BY mth, product
ORDER BY mth ASC, product ASC;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter