Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"solution/1500-1599/1555.Bank Account Summary/Solution.sql",
"solution/1600-1699/1667.Fix Names in a Table/Solution.sql",
"solution/1900-1999/1972.First and Last Call On the Same Day/Solution.sql",
"solution/2600-2699/2686.Immediate Food Delivery III/Solution.sql"
"solution/2600-2699/2686.Immediate Food Delivery III/Solution.sql",
"solution/2700-2799/2752.Customers with Maximum Number of Transactions on Consecutive Days/Solution.sql"
],
"options": {
"parser": "bigquery"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,29 @@ In total, the highest number of consecutive transactions is 3, achieved by custo
<!-- 这里可写当前语言的特殊实现逻辑 -->

```sql

# Write your MySQL query statement below
WITH
s AS (
SELECT
customer_id,
date_sub(
transaction_date,
INTERVAL row_number() OVER (
PARTITION BY customer_id
ORDER BY transaction_date
) DAY
) AS transaction_date
FROM Transactions
),
t AS (
SELECT customer_id, transaction_date, count(1) AS cnt
FROM s
GROUP BY 1, 2
)
SELECT customer_id
FROM t
WHERE cnt = (SELECT max(cnt) FROM t)
ORDER BY customer_id;
```

<!-- tabs:end -->
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,29 @@ In total, the highest number of consecutive transactions is 3, achieved by custo
### **SQL**

```sql

# Write your MySQL query statement below
WITH
s AS (
SELECT
customer_id,
date_sub(
transaction_date,
INTERVAL row_number() OVER (
PARTITION BY customer_id
ORDER BY transaction_date
) DAY
) AS transaction_date
FROM Transactions
),
t AS (
SELECT customer_id, transaction_date, count(1) AS cnt
FROM s
GROUP BY 1, 2
)
SELECT customer_id
FROM t
WHERE cnt = (SELECT max(cnt) FROM t)
ORDER BY customer_id;
```

<!-- tabs:end -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Write your MySQL query statement below
WITH
s AS (
SELECT
customer_id,
date_sub(
transaction_date,
INTERVAL row_number() OVER (
PARTITION BY customer_id
ORDER BY transaction_date
) DAY
) AS transaction_date
FROM Transactions
),
t AS (
SELECT customer_id, transaction_date, count(1) AS cnt
FROM s
GROUP BY 1, 2
)
SELECT customer_id
FROM t
WHERE cnt = (SELECT max(cnt) FROM t)
ORDER BY customer_id;