2023-12-09 18:42:21 +08:00
|
|
|
|
<p>表: <code>Customer</code></p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
+-------------+---------+
|
|
|
|
|
| Column Name | Type |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| id | int |
|
|
|
|
|
| name | varchar |
|
|
|
|
|
| referee_id | int |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
在 SQL 中,id 是该表的主键列。
|
|
|
|
|
该表的每一行表示一个客户的 id、姓名以及推荐他们的客户的 id。</pre>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>找出那些 <strong>没有被</strong> <code>id = 2</code> 的客户 <strong>推荐</strong> 的客户的姓名。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
|
|
|
|
|
|
|
|
|
|
<p>结果格式如下所示。</p>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<b>输入:</b>
|
|
|
|
|
Customer 表:
|
|
|
|
|
+----+------+------------+
|
|
|
|
|
| id | name | referee_id |
|
|
|
|
|
+----+------+------------+
|
|
|
|
|
| 1 | Will | null |
|
|
|
|
|
| 2 | Jane | null |
|
|
|
|
|
| 3 | Alex | 2 |
|
|
|
|
|
| 4 | Bill | null |
|
|
|
|
|
| 5 | Zack | 1 |
|
|
|
|
|
| 6 | Mark | 2 |
|
|
|
|
|
+----+------+------------+
|
|
|
|
|
<b>输出:</b>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
+------+
|
|
|
|
|
| name |
|
|
|
|
|
+------+
|
|
|
|
|
| Will |
|
|
|
|
|
| Jane |
|
|
|
|
|
| Bill |
|
|
|
|
|
| Zack |
|
2023-12-09 18:42:21 +08:00
|
|
|
|
+------+</pre>
|