Running total per customer
Window functionsMedium
For each order, return customer_id, ordered_on, amount and running_total: the customer's cumulative spend up to and including that order. Order by customer then date.
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.