Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Three-day login streaks

    Three-day login streaks

    Hardsqlwindow functionsgaps and islandsdates

    logins records every time a user signed in (possibly several times a day). Return the user_id of every user who signed in on at least three consecutive days at some point, sorted.

    Tables

    • logins (user_id INTEGER, day TEXT)

    Example 1

    logins

    user_idday
    12026-01-01
    12026-01-02
    12026-01-02
    12026-01-03
    22026-01-01
    22026-01-03
    22026-01-04

    Expected result

    user_id
    1

    User 2 missed the 2nd.

    Constraints

    • 0 ≤ rows ≤ 2000
    • day is YYYY-MM-DD
    • The order of rows matters

    Submit checks your solution against 10 tests, including hidden ones.

    SQL
    -- Write one SELECT query. Tables: logins
    SELECT
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.