SQL语句中With Roolup参数的作用
例如:select id, sex, towns, count(*) from user group by sex,towns with rollup
执行结果
相当于依次执行了
select count(*) from user
select id,sex,towns,count(*) from user group by sex
select id,sex,towns,count(*) from user group by sex,towns
说明:
查询结果表明住在town0城镇性别为女的用户有3人,性别为男的用户有6人。
执行顺序依次为(顶层聚合)->(一级聚合)->(二级聚合)