Skip to main content
SQL โ€ข LESSON 189

Monthly Revenue

How can we calculate revenue by month?

Advancedโฑ 3 Minutesโญ 2020 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