If I want a table of figures for the past 18 months, I could aggregate them like so:
GROUP BY DATEDIFF('month', "transaction_date", NOW())
And get a result set that shows the relative month in one column, and the sum in another.And those values relative values won't change every month like they would if I just grouped by
EXTRACT('year-month', "transaction_date")
(or whatever the syntax is for that)Also useful for a stored procedure or view than can then be JOINed in other queries as time goes on.