mysql avg

1.数量错误

avg在不分组的情况下,只显示一组数据

正确为

2.结果不对

select student_id,avg(number) from score where number<60 group by student_id having count(corse_id)>=1;

结果不正确,只是求出了number<60的平均值

select student_id,avg(number) from score where
student_id in (select student_id from score where number < 60 group by student_id having count(corse_id) >=1) group by student_id;
正确

posted on 2019-02-11 18:07  寻找心的巨人  阅读(221)  评论(0)    收藏  举报

导航