1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/每天的领导和合伙人 [daily-leads-and-partners].html

57 lines
2.4 KiB
HTML
Raw Normal View History

2022-03-27 20:45:09 +08:00
<p>表:<code>DailySales</code></p>
<pre>
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| date_id | date |
| make_name | varchar |
| lead_id | int |
| partner_id | int |
+-------------+---------+
2023-12-09 18:42:21 +08:00
该表没有主键(具有唯一值的列)。它可能包含重复项。
2022-03-27 20:45:09 +08:00
该表包含日期、产品的名称,以及售给的领导和合伙人的编号。
名称只包含小写英文字母。</pre>
<p>&nbsp;</p>
2023-12-09 18:42:21 +08:00
<p>对于每一个&nbsp;<code>date_id</code>&nbsp;&nbsp;<code>make_name</code>,找出&nbsp;<strong>不同&nbsp;</strong>&nbsp;<code>lead_id</code>&nbsp;以及&nbsp;<strong>不同&nbsp;</strong>&nbsp;<code>partner_id</code>&nbsp;的数量。</p>
2022-03-27 20:45:09 +08:00
<p><strong>任意顺序</strong> 返回结果表。</p>
2023-12-09 18:42:21 +08:00
<p>返回结果格式如下示例所示。</p>
2022-03-27 20:45:09 +08:00
<p>&nbsp;</p>
<p><strong>示例 1:</strong></p>
<pre>
<strong>输入:</strong>
DailySales 表:
+-----------+-----------+---------+------------+
| date_id | make_name | lead_id | partner_id |
+-----------+-----------+---------+------------+
| 2020-12-8 | toyota | 0 | 1 |
| 2020-12-8 | toyota | 1 | 0 |
| 2020-12-8 | toyota | 1 | 2 |
| 2020-12-7 | toyota | 0 | 2 |
| 2020-12-7 | toyota | 0 | 1 |
| 2020-12-8 | honda | 1 | 2 |
| 2020-12-8 | honda | 2 | 1 |
| 2020-12-7 | honda | 0 | 1 |
| 2020-12-7 | honda | 1 | 2 |
| 2020-12-7 | honda | 2 | 1 |
+-----------+-----------+---------+------------+
<strong>输出:</strong>
+-----------+-----------+--------------+-----------------+
| date_id | make_name | unique_leads | unique_partners |
+-----------+-----------+--------------+-----------------+
| 2020-12-8 | toyota | 2 | 3 |
| 2020-12-7 | toyota | 1 | 2 |
| 2020-12-8 | honda | 2 | 2 |
| 2020-12-7 | honda | 3 | 2 |
+-----------+-----------+--------------+-----------------+
<strong>解释:</strong>
在 2020-12-8丰田toyota有领导者 = [0, 1] 和合伙人 = [0, 1, 2] 同时本田honda有领导者 = [1, 2] 和合伙人 = [1, 2]。
在 2020-12-7丰田toyota有领导者 = [0] 和合伙人 = [1, 2] 同时本田honda有领导者 = [0, 1, 2] 和合伙人 = [1, 2]。</pre>