Skip to content

Commit 215097e

Browse files
committed
feat: add solutions to lc problem: No.1549
No.1549.The Most Recent Orders for Each Product
1 parent 8117658 commit 215097e

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

solution/1500-1599/1537.Get the Maximum Score/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272

7373
<!-- 这里可写通用的实现逻辑 -->
7474

75-
76-
7775
<!-- tabs:start -->
7876

7977
### **Python3**

solution/1500-1599/1549.The Most Recent Orders for Each Product/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,29 @@ hard disk 没有被下单, 我们不把它包含在结果表中.</pre>
124124
### **SQL**
125125

126126
```sql
127-
127+
# Write your MySQL query statement below
128+
select
129+
product_name,
130+
o.product_id,
131+
o.order_id,
132+
o.order_date
133+
from
134+
Orders o
135+
join Products p on o.product_id = p.product_id
136+
where
137+
(o.product_id, order_date) in (
138+
select
139+
product_id,
140+
max(order_date) order_date
141+
from
142+
Orders
143+
group by
144+
product_id
145+
)
146+
order by
147+
product_name,
148+
o.product_id,
149+
o.order_id
128150
```
129151

130152
<!-- tabs:end -->

solution/1500-1599/1549.The Most Recent Orders for Each Product/README_EN.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,29 @@ The hard disk was never ordered and we do not include it in the result table.
120120
### **SQL**
121121

122122
```sql
123-
123+
# Write your MySQL query statement below
124+
select
125+
product_name,
126+
o.product_id,
127+
o.order_id,
128+
o.order_date
129+
from
130+
Orders o
131+
join Products p on o.product_id = p.product_id
132+
where
133+
(o.product_id, order_date) in (
134+
select
135+
product_id,
136+
max(order_date) order_date
137+
from
138+
Orders
139+
group by
140+
product_id
141+
)
142+
order by
143+
product_name,
144+
o.product_id,
145+
o.order_id
124146
```
125147

126148
<!-- tabs:end -->
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Write your MySQL query statement below
2+
select
3+
product_name,
4+
o.product_id,
5+
o.order_id,
6+
o.order_date
7+
from
8+
Orders o
9+
join Products p on o.product_id = p.product_id
10+
where
11+
(o.product_id, order_date) in (
12+
select
13+
product_id,
14+
max(order_date) order_date
15+
from
16+
Orders
17+
group by
18+
product_id
19+
)
20+
order by
21+
product_name,
22+
o.product_id,
23+
o.order_id

0 commit comments

Comments
 (0)