Return every maximal streak of at least three consecutive calendar days per user. Repeated activity on the same day counts once. Dates are valid ISO YYYY-MM-DD strings. Return user_id, start_day, end_day, day_count, ordered by user_id, start_day. A missing day breaks the streak; IDs and insertion order have no chronological meaning.
Schema (all columns are NOT NULL unless explicitly nullable):
CREATE TABLE activity (user_id INTEGER NOT NULL, day TEXT NOT NULL);Write one read-only SQLite query. The tables are already populated. Return exactly the requested columns and ordering, with no headers. Empty input produces no rows unless specified otherwise.
Example setup:
INSERT INTO activity VALUES (1,'2024-01-01'),(1,'2024-01-02'),(1,'2024-01-02'),(1,'2024-01-03');Expected output:
1|2024-01-01|2024-01-03|3Timebox: 9 minutes. Focus on correctness at boundaries and duplicate handling.
Sample tests