本次用到的表信息:
查询某一个字段的数量(count):
select count(SNo) from S;
若为空则总数相应减少对应的null值
select count(dept) from S;
【拓展】:查询专业类型个数
select count(distinct dept) from S;
统计平均年龄(avg)
select avg(age) from s;
统计最大或最小年龄(max 或者min)
select max(age) from s;
统计计算机专业学生年龄之和
select sum(age) '计算机类年龄之和'from s where dept='计算机';
聚合函数代码:(count,max,min,sum,avg)
#win+r
#services.msc 启动mysql
#聚合
select *from S;
select count(SNo) from S;
select count(distinct dept) from S;
select avg(age) from s;
select max(age) from s;
select min(sal+comm) from t;
select sum(age) '计算机类年龄之和'from s where dept='计算机';