What is the Use of "WITH ROLLUP" in Mysql?


Top Questions

www.w3answers.com

Adding a WITH ROLLUP modifier to the GROUP BY clause causes the query to produce another row.

eg:

mysql> SELECT year, SUM(profit) FROM sales GROUP BY year WITH ROLLUP;
+------+-------------+
| year | SUM(profit) |
+------+-------------+
| 2000 | 4525 |
| 2001 | 3010 |
| NULL | 7535 | <<<- Note here*
+------+-------------+

So an extra row (<<<- Note here*) is created by mysql and also we get total profit
in the last column.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Check It !

Tweet It

W3 Updates

Stay informed on our latest news!

Syndicate content