We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab14fe3 commit 979d709Copy full SHA for 979d709
1709-biggest-window-between-visits.sql
@@ -0,0 +1,10 @@
1
+# Write your MySQL query statement below
2
+SELECT user_id, MAX(diff) AS biggest_window
3
+FROM
4
+(
5
+ SELECT user_id,
6
+ DATEDIFF(COALESCE(LEAD(visit_date) OVER (PARTITION BY user_id ORDER BY visit_date), '2021-01-01'), visit_date) AS diff
7
+ FROM userVisits
8
+) a
9
+GROUP BY user_id
10
+ORDER BY user_id;
0 commit comments