Skip to content

Commit 32d6ae6

Browse files
committed
feat: add sql solutions to lc problems: No.1068,1069,1070
1 parent d1ef027 commit 32d6ae6

File tree

9 files changed

+105
-6
lines changed

9 files changed

+105
-6
lines changed

solution/1000-1099/1068.Product Sales Analysis I/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,17 @@ Result 表:
7979
### **SQL**
8080

8181
```sql
82-
82+
# Write your MySQL query statement below
83+
SELECT
84+
p.product_name AS product_name,
85+
s.year AS year,
86+
s.price AS price
87+
FROM
88+
Sales s
89+
LEFT JOIN
90+
Product p
91+
ON
92+
s.product_id = p.product_id;
8393
```
8494

8595
<!-- tabs:end -->

solution/1000-1099/1068.Product Sales Analysis I/README_EN.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,17 @@ From sale_id = 7, we can conclude that Apple was sold for 9000 in the year 2011.
8585
### **SQL**
8686

8787
```sql
88-
88+
# Write your MySQL query statement below
89+
SELECT
90+
p.product_name AS product_name,
91+
s.year AS year,
92+
s.price AS price
93+
FROM
94+
Sales s
95+
LEFT JOIN
96+
Product p
97+
ON
98+
s.product_id = p.product_id;
8999
```
90100

91101
<!-- tabs:end -->
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
p.product_name AS product_name,
4+
s.year AS year,
5+
s.price AS price
6+
FROM
7+
Sales s
8+
LEFT JOIN
9+
Product p
10+
ON
11+
s.product_id = p.product_id;

solution/1000-1099/1069.Product Sales Analysis II/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ Result 表:
7777
### **SQL**
7878

7979
```sql
80-
80+
# Write your MySQL query statement below
81+
SELECT
82+
product_id,
83+
sum(quantity) AS total_quantity
84+
FROM
85+
Sales
86+
GROUP BY
87+
product_id;
8188
```
8289

8390
<!-- tabs:end -->

solution/1000-1099/1069.Product Sales Analysis II/README_EN.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@ Result table:
135135
### **SQL**
136136

137137
```sql
138-
138+
# Write your MySQL query statement below
139+
SELECT
140+
product_id,
141+
sum(quantity) AS total_quantity
142+
FROM
143+
Sales
144+
GROUP BY
145+
product_id;
139146
```
140147

141148
<!-- tabs:end -->
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
product_id,
4+
sum(quantity) AS total_quantity
5+
FROM
6+
Sales
7+
GROUP BY
8+
product_id;

solution/1000-1099/1070.Product Sales Analysis III/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,22 @@ Result table:
7575
### **SQL**
7676

7777
```sql
78-
78+
# Write your MySQL query statement below
79+
SELECT
80+
product_id,
81+
year as first_year,
82+
quantity,
83+
price
84+
FROM
85+
Sales
86+
WHERE
87+
(product_id, year) IN (
88+
SELECT
89+
product_id, min(year) year
90+
FROM
91+
Sales
92+
GROUP BY product_id
93+
);
7994
```
8095

8196
<!-- tabs:end -->

solution/1000-1099/1070.Product Sales Analysis III/README_EN.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,22 @@ Result table:
137137
### **SQL**
138138

139139
```sql
140-
140+
# Write your MySQL query statement below
141+
SELECT
142+
product_id,
143+
year as first_year,
144+
quantity,
145+
price
146+
FROM
147+
Sales
148+
WHERE
149+
(product_id, year) IN (
150+
SELECT
151+
product_id, min(year) year
152+
FROM
153+
Sales
154+
GROUP BY product_id
155+
);
141156
```
142157

143158
<!-- tabs:end -->
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
product_id,
4+
year as first_year,
5+
quantity,
6+
price
7+
FROM
8+
Sales
9+
WHERE
10+
(product_id, year) IN (
11+
SELECT
12+
product_id, min(year) year
13+
FROM
14+
Sales
15+
GROUP BY product_id
16+
);

0 commit comments

Comments
 (0)