group by

group by: 根据by对数据按照哪个字段进行分组,或者是哪几个字段进行分组

select   字段    from   表名   group  by    字段    having    过滤条件

eg:

SELECT id, COUNT(course) as numcourse, AVG(score) as avgscore FROM student GROUP BY id HAVING AVG(score)>=80;

SELECT name FROM student GROUP BY name HAVING min(score)>=80;

posted @ 2021-10-21 20:02  keep2021  阅读(46)  评论(0编辑  收藏  举报