Skip to main content
SQL • LESSON 132

Monthly Revenue

How can we calculate monthly revenue across multiple years?

Advanced3 Minutes1450 XP
🤔 THE QUESTION

How can we calculate monthly revenue across multiple years?

💡 WHAT IS IT?

Grouping by both year and month components generates chronological multi-year monthly revenue rollups.

🎯 WHAT IS IT USED FOR?

Executive financial statements, monthly recurring revenue (MRR) rollups, fiscal reporting.

💻 EXAMPLE
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);

🎯 Mission Objectives

Practice typing production-grade SQL code for Monthly Revenue.

  • Year & Month aggregation
  • Monthly revenue reporting
  • Multi-year rollups
  • Executive financial analytics