Longest Consecutive Login Streak
Hard
Window Functions
For each user return the length of their longest streak of consecutive login days. Each user logs at most once per day in the table. Order by user_id.
Table schema
Logins(user_id INT, login_date DATE)Sample data
user_id | login_date
1 | 2026-03-01
1 | 2026-03-02
1 | 2026-03-03
1 | 2026-03-05
1 | 2026-03-06
2 | 2026-03-01
2 | 2026-03-03
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.