justcode.ikeepstudying.com
Mysql 分组计汇, MySQL中with rollup的用法, group by汇总 - Just Code
Mysql中有一个with rollup是用来在分组统计数据的基础上再进行统计汇总,即用来得到group by的汇总信息; 举例如下: 新建表: create table age ( sno char(4) primary key,sname varchar(10),sage int); 表中数据有: mysql> select * from age; +------+-----------+------+ | sno | sname | sage | +------+-----------+------+ | 1101 | justcode1 | 20 | | 1102 | justcode2 | 21 | | 1103 | justcode3 | 22 | | 1104 | …