Mytable with Id as autoincrement Customer, Date and Amount I want to make a rollup that will sum the amount of every customer every day I mean that the rollup is grouped by Date and Customer This is what should my result look like :
+---------+--------------+--------------+------------+
| Id | Date | Customer | Amount |
+---------+--------------+--------------+------------+
| 1 | 2017-09-19 | B | 10 |
| 4 | 2017-09-19 | B | 15 |
| 8 | 2017-09-19 | B | 02 |
| 6 | 2017-09-19 | B | 18 |
| 5 | 2017-09-19 | B | 05 |
| Total | NULL | B | 50 |
| 9 | 2017-09-19 | C | 11 |
|14 | 2017-09-19 | C | 10 |
| 12 | 2017-09-19 | C | 09 |
| Total | NULL | C | 30 |
| 11 | 2017-09-18 | B | 20 |
| 15 | 2017-09-18 | B | 40 |
| Total | NULL | B | 60 |
| 10 | 2017-09-18 | A | 1 |
| 13 | 2017-09-18 | A | 1 |
| 16 | 2017-09-18 | A | 1 |
| 7 | 2017-09-18 | A | 1 |
| 3 | 2017-09-18 | A | 1 |
| Total | NULL | A | 5 |
| 2 | 2017-09-18 | C | 90 |
| Total | NULL | C | 90 |
I tried :
Select
Mytable.Id,
Mytable. Date,
Mytable.Customer,
Mytable.Amount
From Mytable
GROUP BY Mytable. Date, Mytable.Customer WITH ROLLUP
But this does not work as expected .please help