Skip to content

Commit 9d7f0ec

Browse files
committed
feat: add solution to lc problem: No.2474
No.2474.Customers With Strictly Increasing Purchases
1 parent 2bae413 commit 9d7f0ec

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

solution/2400-2499/2474.Customers With Strictly Increasing Purchases/README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,30 @@ Orders 表:
9090
<!-- 这里可写当前语言的特殊实现逻辑 -->
9191

9292
```sql
93-
93+
# Write your MySQL query statement below
94+
select
95+
customer_id
96+
from
97+
(
98+
select
99+
customer_id,
100+
year(order_date),
101+
sum(price) as total,
102+
year(order_date) - rank() over(
103+
partition by customer_id
104+
order by
105+
sum(price)
106+
) as rk
107+
from
108+
Orders
109+
group by
110+
customer_id,
111+
year(order_date)
112+
) t
113+
group by
114+
customer_id
115+
having
116+
count(distinct rk) = 1;
94117
```
95118

96119
<!-- tabs:end -->

solution/2400-2499/2474.Customers With Strictly Increasing Purchases/README_EN.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,30 @@ Customer 3: The first year is 2017, and the last year is 2018
8585
### **SQL**
8686

8787
```sql
88-
88+
# Write your MySQL query statement below
89+
select
90+
customer_id
91+
from
92+
(
93+
select
94+
customer_id,
95+
year(order_date),
96+
sum(price) as total,
97+
year(order_date) - rank() over(
98+
partition by customer_id
99+
order by
100+
sum(price)
101+
) as rk
102+
from
103+
Orders
104+
group by
105+
customer_id,
106+
year(order_date)
107+
) t
108+
group by
109+
customer_id
110+
having
111+
count(distinct rk) = 1;
89112
```
90113

91114
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Write your MySQL query statement below
2+
select
3+
customer_id
4+
from
5+
(
6+
select
7+
customer_id,
8+
year(order_date),
9+
sum(price) as total,
10+
year(order_date) - rank() over(
11+
partition by customer_id
12+
order by
13+
sum(price)
14+
) as rk
15+
from
16+
Orders
17+
group by
18+
customer_id,
19+
year(order_date)
20+
) t
21+
group by
22+
customer_id
23+
having
24+
count(distinct rk) = 1;

0 commit comments

Comments
 (0)