Skip to main content
SQL • LESSON 189

Monthly Revenue

How can we calculate revenue by month?

Advanced3 Minutes2020 XP
🤔 THE QUESTION

How can we calculate revenue by month?

💡 WHAT IS IT?

Grouping by year and month components with ordered chronological output produces monthly revenue trends.

🎯 WHAT IS IT USED FOR?

Executive financial rollups, monthly recurring revenue tracking, fiscal quarter preparation.

💻 EXAMPLE
SELECT
EXTRACT(YEAR FROM order_date) AS year,
EXTRACT(MONTH FROM order_date) AS month,
SUM(amount) AS revenue
FROM orders
GROUP BY
EXTRACT(YEAR FROM order_date),
EXTRACT(MONTH FROM order_date)
ORDER BY year, month;

🎯 Mission Objectives

Practice typing production-grade SQL code for Monthly Revenue.

  • Monthly revenue trend
  • Chronological sorting
  • Multi-year financial aggregation
  • Executive reporting