Skip to content

Commit 274a01e

Browse files
add 1709
1 parent 7cfe73b commit 274a01e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ _If you like this project, please leave me a star._ ★
10771077

10781078
| # | Title | Solutions | Video | Difficulty | Tag
10791079
|-----|----------------|---------------|---------------|---------------|-------------
1080+
|1709|[Biggest Window Between Visits](https://leetcode.com/problems/biggest-window-between-visits/)|[Solution](../master/database/_1709.sql) || Medium |
10801081
|1693|[Daily Leads and Partners](https://leetcode.com/problems/daily-leads-and-partners/)|[Solution](../master/database/_1693.sql) || Easy |
10811082
|1683|[Invalid Tweets](https://leetcode.com/problems/invalid-tweets/)|[Solution](../master/database/_1683.sql) || Easy |
10821083
|1677|[Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices/)|[Solution](../master/database/_1677.sql) || Easy |

database/_1709.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--# Write your MySQL query statement below
2+
with diff_table as (
3+
select user_id, datediff(lead(visit_date, 1, '2021-1-1') over (partition by user_id order by visit_date), visit_date) as diff from UserVisits
4+
)
5+
6+
select user_id, max(diff) as biggest_window from diff_table group by user_id order by user_id

0 commit comments

Comments
 (0)