Interview practice question
Users who logged in three days in a row
Data Engineering · SQL · Intermediate
From a logins table, find users who logged in on at least 3 consecutive days.
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Deduplicate to one row per user per day.
- Use date minus ROW_NUMBER days to build a streak key.
- GROUP BY user and streak key, count days.
- Keep users with count >= 3.
- Alternatively compare LAG with 1 and 2 rows back.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.