SQL 查询出成绩表中成绩大于 90 的学生名字
SQL 面试 大约 1004 字成绩表
mysql> select * from test_score;
+----+---------+---------+-------+
| id | student | subject | score |
+----+---------+---------+-------+
| 1 | 张三 | 语文 | 95 |
| 2 | 张三 | 数学 | 95 |
| 3 | 张三 | 英语 | 95 |
| 4 | 李四 | 语文 | 95 |
| 5 | 李四 | 数学 | 85 |
| 6 | 李四 | 英语 | 95 |
| 7 | 王五 | 语文 | 85 |
| 8 | 王五 | 数学 | 80 |
| 9 | 王五 | 英语 | 95 |
+----+---------+---------+-------+
问题一
查找出每门课成绩都大于等于90
的学生名字
select * from test_score group by student HAVING MIN(score) >= 90
输出:
mysql> select student from test_score group by student HAVING MIN(score) >= 90;
+---------+
| student |
+---------+
| 张三 |
+---------+
问题二
两门或两门以上的课成绩大于等于90
select student from test_score where score >= 90 group by student HAVING count(student) >= 2
输出:
mysql> select student from test_score where score >= 90 group by student HAVING count(student) >= 2;
+---------+
| student |
+---------+
| 张三 |
| 李四 |
+---------+
阅读 2176 · 发布于 2022-04-12
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Vue provide inject 组件传值阅读 65
-
Angular Material mat-error 组件输入时不校验解决方法阅读 1572
-
Test.class found in top-level directory (unnamed package not allowed in module)阅读 3366
-
Spring 事务失效的几种场景阅读 925
-
设计模式之桥接模式阅读 2207
-
OpenLDAP 使用 slappasswd 生成密码阅读 617
-
Golang 定时任务阅读 1359
-
MySQL 合并字符串函数:CONCAT、CONCAT_WS、GROUP_CONCAT阅读 3648
-
MySQL 命令行纵向打印阅读 1961
-
Windows 子系统初始化报错:参考的对象类型不支持尝试的操作阅读 3634