(十五)聚合查询
--1.distinct去重重复数据
select distinct sex from classes;
select count(sex),count(distinct sex) from classes;
--2.cube汇总
--cube汇总和compute效果类似,但语法较简洁,而且返回的是一个结果集。
select count(*), sex from classes group by sex with cube;
select count(*), age, sum(age) from classes where age is not null group by age with cube;
--cube要结合group by语句完成分组汇总

浙公网安备 33010602011771号