Users can log in to the Jira app many times per day. A streak is a run of consecutive calendar days with at least one login. For every user return user_id, longest_streak_days, streak_start and streak_end (dates 'YYYY-MM-DD') of their longest streak; if two streaks tie, report the earliest one. Order by longest_streak_days DESC, then user_id.
| Column | Type |
|---|---|
| user_id | INTEGER |
| login_ts | TIMESTAMP |
| user_id | login_ts |
|---|---|
| 101 | 2026-03-01 08:00:00 |
| 101 | 2026-03-01 21:00:00 |
| 101 | 2026-03-02 09:00:00 |
| 101 | 2026-03-03 09:30:00 |
| 101 | 2026-03-05 10:00:00 |
| 102 | 2026-03-02 11:00:00 |
| 102 | 2026-03-03 11:00:00 |
| 102 | 2026-03-07 11:00:00 |
| user_id | longest_streak_days | streak_start | streak_end |
|---|---|---|---|
| 102 | 4 | 2026-03-07 | 2026-03-10 |
| 101 | 3 | 2026-03-01 | 2026-03-03 |
| 103 | 1 | 2026-03-04 | 2026-03-04 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Cohort LTV by First Purchase Month · Merge Overlapping Driver Online Sessions ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.