Rollup command ..last row of the result will show the total of sum and count function
SELECT month,sum(star),sum(rating),count(*) FROM `rolluptest` group by month with rollup
+-------+-----------+-------------+----------+
| month | sum(star) | sum(rating) | count(*) |
+-------+-----------+-------------+----------+
| Feb | 19 | 4 | 3 |
| Jan | 9 | 4 | 2 |
| Mar | 1 | 3 | 1 |
| NULL | 29 | 11 | 6 |
+-------+-----------+-------------+----------+
SELECT month,sum(star),sum(rating),count(*) FROM `rolluptest` group by month with rollup
+-------+-----------+-------------+----------+
| month | sum(star) | sum(rating) | count(*) |
+-------+-----------+-------------+----------+
| Feb | 19 | 4 | 3 |
| Jan | 9 | 4 | 2 |
| Mar | 1 | 3 | 1 |
| NULL | 29 | 11 | 6 |
+-------+-----------+-------------+----------+
Comments
Post a Comment