How can we calculate monthly revenue across multiple years?
Grouping by both year and month components generates chronological multi-year monthly revenue rollups.
Executive financial statements, monthly recurring revenue (MRR) rollups, fiscal reporting.
SELECT
EXTRACT(YEAR FROM order_date) AS order_year,
EXTRACT(MONTH FROM order_date) AS order_month,
SUM(amount) AS revenue
FROM orders
GROUP BY
EXTRACT(YEAR FROM order_date),
EXTRACT(MONTH FROM order_date);Practice typing production-grade SQL code for Monthly Revenue.