1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/订单最多的客户 [customer-placing-the-largest-number-of-orders].html

51 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>表:&nbsp;<code>Orders</code></p>
<pre>
+-----------------+----------+
| Column Name | Type |
+-----------------+----------+
| order_number | int |
| customer_number | int |
+-----------------+----------+
在 SQL 中Order_number是该表的主键。
此表包含关于订单ID和客户ID的信息。
</pre>
<p>&nbsp;</p>
<p>查找下了 <strong>最多订单</strong>&nbsp;的客户的 <code>customer_number</code></p>
<p>测试用例生成后, <strong>恰好有一个客户</strong> 比任何其他客户下了更多的订单。</p>
<p>查询结果格式如下所示。</p>
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong>
Orders 表:
+--------------+-----------------+
| order_number | customer_number |
+--------------+-----------------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 3 |
+--------------+-----------------+
<strong>输出:</strong>
+-----------------+
| customer_number |
+-----------------+
| 3 |
+-----------------+
<strong>解释:</strong>
customer_number 为 '3' 的顾客有两个订单,比顾客 '1' 或者 '2' 都要多,因为他们只有一个订单。
所以结果是该顾客的 customer_number ,也就是 3 。
</pre>
<p>&nbsp;</p>
<p><strong>进阶:</strong> 如果有多位顾客订单数并列最多,你能找到他们所有的 <code>customer_number</code> 吗?</p>