mysql中使用WITH ROLLUP_mybatis

1:例子,有一张book表

mysql中使用WITH ROLLUP_mybatis_02

 

2:执行sql求和

SELECT
sum(age)
FROM
student
GROUP BY
age;

mysql中使用WITH ROLLUP_数据库_03

 

3:加上with ROLLUP 查询结果会加上一行,显示总和

SELECT
sum(age)
FROM
student
GROUP BY
age with ROLLUP;

mysql中使用WITH ROLLUP_sql_04