2022-03-27 20:46:41 +08:00
|
|
|
|
<p>表: <code>Courses</code></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| Column Name | Type |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| student | varchar |
|
|
|
|
|
| class | varchar |
|
|
|
|
|
+-------------+---------+
|
2023-12-09 18:42:21 +08:00
|
|
|
|
在 SQL 中,(student, class)是该表的主键列。
|
2022-03-27 20:46:41 +08:00
|
|
|
|
该表的每一行表示学生的名字和他们注册的班级。
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>查询 <strong>至少有5个学生</strong> 的所有班级。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<p>以 <strong>任意顺序 </strong>返回结果表。</p>
|
|
|
|
|
|
|
|
|
|
<p>查询结果格式如下所示。</p>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>
|
|
|
|
|
Courses table:
|
|
|
|
|
+---------+----------+
|
|
|
|
|
| student | class |
|
|
|
|
|
+---------+----------+
|
|
|
|
|
| A | Math |
|
|
|
|
|
| B | English |
|
|
|
|
|
| C | Math |
|
|
|
|
|
| D | Biology |
|
|
|
|
|
| E | Math |
|
|
|
|
|
| F | Computer |
|
|
|
|
|
| G | Math |
|
|
|
|
|
| H | Math |
|
|
|
|
|
| I | Math |
|
|
|
|
|
+---------+----------+
|
|
|
|
|
<strong>输出:</strong>
|
|
|
|
|
+---------+
|
|
|
|
|
| class |
|
|
|
|
|
+---------+
|
|
|
|
|
| Math |
|
|
|
|
|
+---------+
|
|
|
|
|
<strong>解释: </strong>
|
|
|
|
|
-数学课有6个学生,所以我们包括它。
|
|
|
|
|
-英语课有1名学生,所以我们不包括它。
|
|
|
|
|
-生物课有1名学生,所以我们不包括它。
|
|
|
|
|
-计算机课有1个学生,所以我们不包括它。</pre>
|