New vs Returning Riders by Month

For each month, split riders with a completed trip into new riders (their first completed trip ever was in that month) and returning riders (their first completed trip was in an earlier month).

Expected output

month (YYYY-MM), new_riders, returning_riders. Sorted by month.

Row order is checked. Column names are not checked; numbers are compared to 2 decimals.

Dataset: Ride-share marketplace

Trip requests in four US cities from January to March 2026, with drivers, riders, fares and ratings.

drivers

One row per driver. A driver only serves their own city.

driver_idINTEGERprimary key
nameTEXT
cityTEXT
joined_dateTEXTYYYY-MM-DD
vehicle_typeTEXTstandard, comfort or xl
riders

One row per rider account.

rider_idINTEGERprimary key
nameTEXT
cityTEXT
signup_dateTEXTYYYY-MM-DD
trips

One row per trip request, whatever its outcome.

trip_idINTEGERprimary key, increases with requested_at
rider_idINTEGER
driver_idINTEGERNULL when no driver was assigned
cityTEXT
requested_atTEXTYYYY-MM-DD HH:MM:SS (UTC)
dropoff_atTEXTNULL unless completed
statusTEXTcompleted, cancelled_rider, cancelled_driver or no_driver
distance_kmREALestimated route distance
fareREALUSD, NULL unless completed
rider_ratingINTEGER1-5 stars given by the rider, NULL if not rated

Engine: SQLite. Dates are text (YYYY-MM-DD); use strftime(), date() and julianday() for date math.

Related problems

SQLite · runs in your browser
Ctrl/⌘ + Enter to run
Expected output preview (3 rows, order matters)
monthnew_ridersreturning_riders
2026-01610
2026-02940
2026-03642

Hints

Worked solution

Run at least one query to unlock it.