Getting started: filtering your data Let's start by examining an example payments table. Our goal is to roll up old months and put them into a summary table. To begin, we need to filter down to just older months: SQL SELECT amount , YEAR ( payment_date ) , MONTH ( payment_date ) FROM payments WHERE payment_date < DATE_FORMAT ( CURRENT_DATE , '%Y-%m-01' ) Here, we're selecting the amount of the payment as well as the year and month that the payment was made. By limiting the results to payment_date values that are less than the first day of the current month, we ensure that we're only selecting data from previous months. Grouping your data Once we have our filtered data, we need to group it by year and month so we can roll it up into the summary table: SQL SELECT sum ( amount ) as amount , YEAR ( payment_date ) as ` year ` , MONTH ( payment_date ) as ` month ` FROM payments WHERE payment_date < ...