Interview Query

7 Day Streak

8
Have you seen this question before?

Given a table with event logs, find the percentage of users that had at least one seven-day streak of visiting the same URL.

Note: Round the results to 2 decimal places. For example, if the result is 35% return 0.35.

Example:

Input:

events table

Column Type
user_id INTEGER
created_at DATETIME
url VARCHAR

Output

Column Type
output FLOAT
Next question: Delivery Online
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query