SelectItem,SUM(Price)ASPricefromratelistGroupbyitemWITHROLLUP;+------+-------+|Item|Price|+------+-------+|A | 502"/> SelectItem,SUM(Price)ASPricefromratelistGroupbyitemWITHROLLUP;+------+-------+|Item|Price|+------+-------+|A | 502">

Home  >  Article  >  Database  >  What is the use of WITH ROLLUP modifier in MySQL?

What is the use of WITH ROLLUP modifier in MySQL?

王林
王林forward
2023-09-07 20:17:091252browse

MySQL中WITH ROLLUP修饰符有什么用?

"WITH ROLLUP" is a modifier used with the GROUP BY clause. Mainly, it causes the summary output to contain extra lines representing higher-level summary operations.

Example

In the following example, the WITH ROLLUP modifier gives the summary output total price in an extra row.

mysql> Select Item, SUM(Price) AS Price from ratelist Group by item WITH ROLLUP;
+------+-------+
| Item | Price |
+------+-------+
| A    |   502 |
| B    |   630 |
| C    |  1005 |
| h    |   850 |
| T    |   250 |
| NULL |  3237 |
+------+-------+
6 rows in set (0.00 sec)

The above is the detailed content of What is the use of WITH ROLLUP modifier in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete