EasyGROUP BY & Aggregation

Monthly revenue report

The query

SQL
SELECT
  EXTRACT(YEAR FROM order_date) AS year,
  EXTRACT(MONTH FROM order_date) AS month,
  COUNT(*) AS order_count,
  SUM(total) AS monthly_revenue
FROM orders
WHERE status = 'completed'
GROUP BY year, month
ORDER BY year, month;
Tested against PostgreSQL 16

Note

Date truncation for time-series aggregation. Use TO_CHAR for formatted month names.

Tables referenced