Uber-style Company ChallengeEasyVerified answerSQLite live

Cash Payment Trips

Which completed trips were paid in cash, and who were the rider and driver?

  • Joins
  • Filtering
  • Sorting

Challenge brief

Understand the request

Finance Operations needs to audit cash transactions separately from digital payments for regulatory reconciliation.

List all cash-payment trips showing rider name, driver name, and fare amount.

Return

  • trip_id
  • rider_name (full name)
  • driver_name (full name)
  • fare_amount
  • payment_method

Constraints

  • Return only completed trips paid with 'cash'
  • Order by fare amount descending, then trip ID

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

trips

  • trip_idINTEGER
  • rider_idINTEGER
  • driver_idINTEGER
  • fare_amountREAL
  • payment_methodVARCHAR(30)

riders

  • rider_idINTEGER
  • first_nameVARCHAR(50)
  • last_nameVARCHAR(50)

drivers

  • driver_idINTEGER
  • first_nameVARCHAR(50)
  • last_nameVARCHAR(50)

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Cash trips are identified by payment_method = 'cash' in trips. You need rider and driver names from their respective tables — two INNER JOINs.

Hint 2

INNER JOIN trips to riders on rider_id, and to drivers on driver_id. WHERE t.payment_method = 'cash'.

Hint 3

Join qualifying trip facts to both people dimensions, apply status and payment filters, and stabilize equal fares with the trip key.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT t.trip_id, r.first_name || ' ' || r.last_name AS rider_name, d.first_name || ' ' || d.last_name AS driver_name, t.fare_amount, t.payment_method FROM trips t INNER JOIN riders r ON t.rider_id = r.rider_id INNER JOIN drivers d ON t.driver_id = d.driver_id WHERE t.trip_status = 'completed' AND t.payment_method = 'cash' ORDER BY t.fare_amount DESC, t.trip_id

Why this works

Only trip 1003 (Times Square to Brooklyn) was paid in cash. All other trips used credit_card. The two INNER JOINs bring in both the rider and driver names from a single trips row.

Success check

1 cash trip — Carol Clark / Mike Johnson, $28

Expected result

Use this output to verify values, aliases, ordering, and row count.

trip_idrider_namedriver_namefare_amountpayment_method
1003Carol ClarkMike Johnson28cash

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Interview Practice

Return to the complete interview preparation experience.