Interview Query

Longest Streak Users

23
Have you seen this question before?

Given a table with event logs, find the top five users with the longest continuous streak of visiting the platform in 2020.

Note: A continuous streak counts if the user visits the platform at least once per day on consecutive days.

Example:

Input:

events table

Column Type
user_id INTEGER
created_at DATETIME
url VARCHAR

Output:

Column Type
user_id INTEGER
streak_length INTEGER
Next question: Regress Y on X
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query