Monthly Revenue
Medium · Dates
date_trunc('month', d) rounds a date down to the first day of its month. It returns a timestamp, so add ::date to get a plain date back.
For paid orders only, return one row per month with month (a date: the first day of the month, like 2026-03-01), paid_orders (how many paid orders) and revenue (sum of total). Months without paid orders are left out. Sort by month.
Next: Overdue Loans