Skip to content

Commit b0cd9c2

Browse files
committed
task: #1068
1 parent 215caf9 commit b0cd9c2

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Have a good contributing!
4646
- [610. Triangle Judgement](./leetcode/easy/610.%20Triangle%20Judgement.sql)
4747
- [619. Biggest Single Number](./leetcode/easy/619.%20Biggest%20Single%20Number.sql)
4848
- [620. Not Boring Movies](./leetcode/easy/620.%20Not%20Boring%20Movies.sql)
49+
- [1068. Product Sales Analysis I](./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql)
4950
2. [Medium](./leetcode/medium/)
5051
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
5152
- [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Question 1068. Product Sales Analysis I
3+
Link: https://leetcode.com/problems/product-sales-analysis-i/description/
4+
5+
Table: Sales
6+
7+
+-------------+-------+
8+
| Column Name | Type |
9+
+-------------+-------+
10+
| sale_id | int |
11+
| product_id | int |
12+
| year | int |
13+
| quantity | int |
14+
| price | int |
15+
+-------------+-------+
16+
(sale_id, year) is the primary key (combination of columns with unique values) of this table.
17+
product_id is a foreign key (reference column) to Product table.
18+
Each row of this table shows a sale on the product product_id in a certain year.
19+
Note that the price is per unit.
20+
21+
22+
Table: Product
23+
24+
+--------------+---------+
25+
| Column Name | Type |
26+
+--------------+---------+
27+
| product_id | int |
28+
| product_name | varchar |
29+
+--------------+---------+
30+
product_id is the primary key (column with unique values) of this table.
31+
Each row of this table indicates the product name of each product.
32+
33+
34+
Write a solution to report the product_name, year, and price for each sale_id in the Sales table.
35+
36+
Return the resulting table in any order.
37+
*/
38+
39+
SELECT
40+
p.product_name,
41+
s.year,
42+
s.price
43+
FROM Sales AS s
44+
LEFT JOIN
45+
Product AS p
46+
ON s.product_id = p.product_id

0 commit comments

Comments
 (0)