Monthly revenue with month-over-month change
Window functionsMedium
Return month (YYYY-MM), revenue and change (revenue minus the previous month's; NULL for the first month), ordered by month. Round money to 2 decimals.
Tables
customers: id, name, email, countryorders: id, customer_id, ordered_on (YYYY-MM-DD), amount
Row order is checked. Column names do not have to match, but the number of columns and the values do.