2022-03-27 20:37:52 +08:00
|
|
|
|
<p>表 <code>Activities</code>:</p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| 列名 | 类型 |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| sell_date | date |
|
|
|
|
|
| product | varchar |
|
|
|
|
|
+-------------+---------+
|
2023-12-09 18:42:21 +08:00
|
|
|
|
该表没有主键(具有唯一值的列)。它可能包含重复项。
|
2022-03-27 20:37:52 +08:00
|
|
|
|
此表的每一行都包含产品名称和在市场上销售的日期。
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>编写解决方案找出每个日期、销售的不同产品的数量及其名称。<br />
|
2022-03-27 20:37:52 +08:00
|
|
|
|
每个日期的销售产品名称应按词典序排列。<br />
|
|
|
|
|
返回按 <code>sell_date</code> 排序的结果表。<br />
|
2023-12-09 18:42:21 +08:00
|
|
|
|
结果表结果格式如下例所示。</p>
|
2022-03-27 20:37:52 +08:00
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<code><strong>输入:</strong>
|
|
|
|
|
Activities</code> 表:
|
|
|
|
|
+------------+-------------+
|
|
|
|
|
| sell_date | product |
|
|
|
|
|
+------------+-------------+
|
|
|
|
|
| 2020-05-30 | Headphone |
|
|
|
|
|
| 2020-06-01 | Pencil |
|
|
|
|
|
| 2020-06-02 | Mask |
|
|
|
|
|
| 2020-05-30 | Basketball |
|
|
|
|
|
| 2020-06-01 | Bible |
|
|
|
|
|
| 2020-06-02 | Mask |
|
|
|
|
|
| 2020-05-30 | T-Shirt |
|
|
|
|
|
+------------+-------------+
|
|
|
|
|
<strong>输出:</strong>
|
|
|
|
|
+------------+----------+------------------------------+
|
|
|
|
|
| sell_date | num_sold | products |
|
|
|
|
|
+------------+----------+------------------------------+
|
|
|
|
|
| 2020-05-30 | 3 | Basketball,Headphone,T-shirt |
|
|
|
|
|
| 2020-06-01 | 2 | Bible,Pencil |
|
|
|
|
|
| 2020-06-02 | 1 | Mask |
|
|
|
|
|
+------------+----------+------------------------------+
|
|
|
|
|
<strong>解释:</strong>
|
|
|
|
|
对于2020-05-30,出售的物品是 (Headphone, Basketball, T-shirt),按词典序排列,并用逗号 ',' 分隔。
|
|
|
|
|
对于2020-06-01,出售的物品是 (Pencil, Bible),按词典序排列,并用逗号分隔。
|
2023-12-09 18:42:21 +08:00
|
|
|
|
对于2020-06-02,出售的物品是 (Mask),只需返回该物品名。
|
|
|
|
|
</pre>
|