mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-13 01:15:14 +08:00
update
This commit is contained in:
@@ -13,30 +13,20 @@
|
||||
(sale_id, year) 是这张表的主键(具有唯一值的列的组合)。
|
||||
product_id 是产品表的外键(reference 列)。
|
||||
这张表的每一行都表示:编号 product_id 的产品在某一年的销售额。
|
||||
一个产品可能在同一年内有多个销售条目。
|
||||
请注意,价格是按每单位计的。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>产品表 <code>Product</code>:</p>
|
||||
|
||||
<pre>
|
||||
+--------------+---------+
|
||||
| Column Name | Type |
|
||||
+--------------+---------+
|
||||
| product_id | int |
|
||||
| product_name | varchar |
|
||||
+--------------+---------+
|
||||
product_id 是这张表的主键(具有唯一值的列)。
|
||||
这张表的每一行都标识:每个产品的 id 和 产品名称。</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>编写解决方案,选出每个售出过的产品 <strong>第一年</strong> 销售的 <strong>产品 id</strong>、<strong>年份</strong>、<strong>数量 </strong>和 <strong>价格</strong>。</p>
|
||||
|
||||
<p>结果表中的条目可以按 <strong>任意顺序</strong> 排列。</p>
|
||||
<ul>
|
||||
<li>对每个 <code>product_id</code>,找到其在Sales表中首次出现的最早年份。</li>
|
||||
<li>返回该产品在该年度的 <strong>所有</strong> 销售条目。</li>
|
||||
</ul>
|
||||
|
||||
<p>结果格式如下例所示:</p>
|
||||
<p>返回一张有这些列的表:<strong>product_id</strong>,<strong>first_year</strong>,<strong>quantity </strong>和<strong> price</strong>。</p>
|
||||
|
||||
<p>结果表中的条目可以按 <strong>任意顺序</strong> 排列。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
@@ -52,14 +42,6 @@ Sales 表:
|
||||
| 2 | 100 | 2009 | 12 | 5000 |
|
||||
| 7 | 200 | 2011 | 15 | 9000 |
|
||||
+---------+------------+------+----------+-------+
|
||||
Product 表:
|
||||
+------------+--------------+
|
||||
| product_id | product_name |
|
||||
+------------+--------------+
|
||||
| 100 | Nokia |
|
||||
| 200 | Apple |
|
||||
| 300 | Samsung |
|
||||
+------------+--------------+
|
||||
<strong>输出:</strong>
|
||||
+------------+------------+----------+-------+
|
||||
| product_id | first_year | quantity | price |
|
||||
|
Reference in New Issue
Block a user