服务器之家:专注于服务器技术及软件下载分享
分类导航

Mysql|Mssql|Oracle|Redis|

服务器之家 - 数据库 - Mysql - mysql 查询表中平均分最低的班级

mysql 查询表中平均分最低的班级

2019-10-30 17:43mysql教程网 Mysql

查询出dd(user_id,class_no,score)这个表中平均分最低的班级?

代码如下:

drop table if exists dd; 
create table dd ( 
user_id int , 
class_no int , 
score int 
); 
insert into dd values (1,1,1), (2,1,1), (3,1,2), (4,2,2); 
select class_no ,avg(score)from dd group by class_no order by avg(score); 

在MySQL下面测试通过。

延伸 · 阅读

精彩推荐