[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
--查询学生平均分数 --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