WITH ROLLUP Modifier

WITH ROLLUP Modifier

WITH ROLLUP Modifier:
We can use this modifier with GROUP BY clause to get summary output.
Syntax:
SELECT [col_name1,col_name2,…] FROM [tab_name] GROUP BY [col_name] WITH ROLLUP;

Example:
SELECT doc_id,sum(total_count) FROM wordlist GROUP BY doc_id WITH ROLLUP;

Output
+——–+——————————-+
| docid | sum(total_count)    |
+——–+——————————-+
| 12     | 123                         |
| 15     | 3423                       |
| NULL | 3546                       |
+——–+————————–+

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.