指定变量值,有多少个这样的行
select COUNT(*) as count1 from student --as为列命名为count1
where cid=1
最大年纪值 / R语言为小写
select MAX(age) from student
白虎班的年龄平均,用到内连接
select AVG(age)
from class
inner join student on class.cid=student.cid
over函数和聚合函数结合,如果不用over,则会报错
select student.*,avg(age) over()
from student
where cid=2
统计1,2班人数,分组后信息被屏蔽,只能拿到分组那个数值和聚合函数的值
select cid, Count(*)
from student
group by cid
分组求年龄平均值
select cid,avg(age) from student
group by cid
每个班的男女生人数
select gender,cid,count(*)
from student
group by gender,cid
select * from student
统计学生编号大于2的各班级的各性别的学生人数
select gender,cid,count(*)
from student
where id>2
group by gender,cid
统计学生编号大于2的各班级的各性别的学生大于1的人数
select gender,cid,count(*)
from student
where id>2
group by gender,cid having count(*)>1 --having表示分组之后再做运算
0.9178
1
1
关注作者
收藏
发表评论
暂无数据

