--查询学生平均分数 --round保留小数2位,avg求平均分,把xuehao 列名显示为学号、把score列名显示为平均分 select xuehao 学号
,round(avg(score),2) 平均分 from SC group by xuehao --通过xuehao分组 --查询每位学生选修的课程门
select xuehao 学号,count(1) 课程门数 --count()函数中往往用数字1或者*,因为任何列都可以统计函数行数 --
查询每门课程的最高分、最低分、平均分 select cid 课程号,max(score) 最高分,min(score) 最低分,avg(score) 平均分
from SC group by cid --查询平均分大于80分学生的学号和平均分 select xuehao 学号,round(avg(score),2)
平均分from SC group by xuehao having round(avg(score),2)>80 --查询男生的平均分 --从SC
表里查询xuehao。查询score的平均值,小数保留两位 select xuehao 学号,round(avg(score),2)from SC --
先执行括号里面的(在shudent表里根据cid查询出男生),再查平均分 whereSC.xuehao in(select xuehao from
Student where gender='男') --通过学号分组 group by xuehao --大于75,结果保留两位小数 having round(
avg(score),2)>75 --排序方向:升序asc,降序desc,asc可省略 order by round(avg(score),2) desc --
根据生日排序 select*from Student order by grade desc,class,birthday desc

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信