Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Running total of payments

    Running total of payments

    Mediumsqlwindow functions

    For each payment return paid_on, amount and running_total = the sum of all payments up to and including this one (ordered by paid_on, then id). Return rows in that same order.

    Tables

    • payments (id INTEGER, paid_on TEXT, amount INTEGER)

    Example 1

    payments

    idpaid_onamount
    12026-01-03100
    22026-01-0150
    32026-01-0325

    Expected result

    paid_onamountrunning_total
    2026-01-015050
    2026-01-03100150
    2026-01-0325175

    Constraints

    • 0 ≤ rows ≤ 1000
    • paid_on is YYYY-MM-DD
    • The order of rows matters

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

    SQL
    -- Write one SELECT query. Tables: payments
    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.