mysql 获取学生个人科目平均分
2024-09-20 03:46:16
mysql> select * from test;
+----+----------+-------+-----------+
| id | name | score | subject |
+----+----------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | xiaobai | | english |
| | xiaobai | | physics |
| | xiaobai | | shuxue |
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+----------+-------+-----------+
rows in set (0.00 sec) mysql> select name,avg(score) from test group by name;
+----------+------------+
| name | avg(score) |
+----------+------------+
| xiaobai | 80.0000 |
| xiaohei | 80.0000 |
| xiaohong | 82.2500 |
| xiaoming | 82.2500 |
+----------+------------+
rows in set (0.01 sec) mysql> select name,sum(score)/count(*) from test group by name;
+----------+---------------------+
| name | sum(score)/count(*) |
+----------+---------------------+
| xiaobai | 80.0000 |
| xiaohei | 80.0000 |
| xiaohong | 82.2500 |
| xiaoming | 82.2500 |
+----------+---------------------+
rows in set (0.00 sec)
最新文章
- window.name实现的跨域数据传输
- java中的23中设计模式(转)
- Android异常:唤醒锁未授权。(Caused by: java.lang.SecurityException: Neither user 10044 nor current process has android.permission.WAKE_LOCK.)
- iOS开发进阶
- 更新引用google的cdn外部jQuery核心库JS文件
- java学习之(接口)
- build a git repo and clone
- 【上传AppStore】iOS项目上传到AppStore步骤流程(第三章) - 基本信息总汇
- windows下部署 ISCSI存储
- Microsoft Visual Studio 2010 Service Pack 1(exe)
- 【破解】破解ACDSEE15的方法
- delphi edit编辑框使用
- MYSQL的日志与备份还原
- Odoo11入门请假单模块学习教程源码
- FTP、FTPS和SFTP
- C#(在WeBAPI)获取Oracle(在PL/SQL)游标类型的存储过程(用到了RefCursor)
- eclipse git(版本回退)
- 不同CSS技术及其CSS性能
- MySQL性能优化之道
- linux下subversion的安装