Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Monthly revenue

    Monthly revenue

    Mediumsqlgroup bydateswhere

    Return month (as YYYY-MM) and revenue = the sum of amount over orders whose status is paid. Months without paid orders are omitted. Sort by month.

    Tables

    • orders (id INTEGER, ordered_on TEXT, amount INTEGER, status TEXT)

    Example 1

    orders

    idordered_onamountstatus
    12026-01-05300paid
    22026-01-20200refunded
    32026-02-01150paid
    42026-01-31100paid

    Expected result

    monthrevenue
    2026-01400
    2026-02150

    Constraints

    • 0 ≤ rows ≤ 1000
    • ordered_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: orders
    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.