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

What is the use of WITH ROLLUP modifier in MySQL?

王林
Release: 2023-09-07 20:17:09
forward
1289 people have browsed it

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template