I would like to output in sql a table that contains the monthly sales per customer. Each column should correspond to another month.
First column should be current month example my sql columns are:
- customer
- invoicedate
- sales
Original table looks like this:
+------------+------------+---------+
| Customer | invdate | sales |
+------------+------------+---------+
| Best Buy | 03-12-2019 | 433 |
| Walmart | 03-15-2019 | 543 |
| Home Depot | 12-12-2018 | 32 |
+------------+------------+---------+
Desired Output:
+------------+----------+--------+--------+--------+--------+----------+
| Customer | March 19 | Feb 19 | Jan 19 | Dec 18 | Nov 18 | Oct 18 |
+------------+----------+--------+--------+--------+--------+----------+
| Home Depot | 100 | 300 | 244 | 32 | 322 | 43 |
| Walmart | 543 | 222 | 234 | 12 | 234 | 34 |
| Bestbuy | 433 | 323 | 323 | 23 | 433 | 34 |
+------------+----------+--------+--------+--------+--------+----------+