Meta's growth team is studying habit formation. A login streak is a run of consecutive calendar days on which a user logged in at least once. A user may log in several times on the same day, and streaks can cross month boundaries. Write an SQL query that returns every user whose longest streak is at least 3 days, with columns `user_id` and `longest_streak` (the length in days of that user's longest streak). Order the results by `longest_streak` descending, then `user_id` ascending.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.