Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Daily cancellation rate

    Daily cancellation rate

    Hardsqljoingroup bycase

    trips have a status (completed or cancelled); riders marks who is banned = 1. For each day, compute rate = cancelled trips ÷ all trips, ignoring trips whose rider is banned, rounded to two decimals. Days with no trips left are omitted. Sort by day.

    Tables

    • trips (id INTEGER, rider_id INTEGER, status TEXT, day TEXT)
    • riders (id INTEGER, banned INTEGER)

    Example 1

    trips

    idrider_idstatusday
    11completed2026-01-01
    22cancelled2026-01-01
    33cancelled2026-01-01
    41completed2026-01-02

    riders

    idbanned
    10
    20
    31

    Expected result

    dayrate
    2026-01-010.5
    2026-01-020

    Day 1: rider 3 is banned, leaving two trips with one cancelled = 0.5.

    Constraints

    • 0 ≤ rows ≤ 1000
    • The order of rows matters

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

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