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_idINTEGERrider_idINTEGERdriver_idINTEGERfare_amountREALpayment_methodVARCHAR(30)
riders
rider_idINTEGERfirst_nameVARCHAR(50)last_nameVARCHAR(50)
drivers
driver_idINTEGERfirst_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_idWhy 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_id | rider_name | driver_name | fare_amount | payment_method |
|---|---|---|---|---|
| 1003 | Carol Clark | Mike Johnson | 28 | cash |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Explore related company challenges
Airbnb
Independent Airbnb-style marketplace, booking, listing, payment, review, and guest analytics SQL practice.
Amazon
Independent Amazon-style e-commerce, warehouse, inventory, and customer analytics SQL practice.
Google
Independent Google-style search, advertising, user-engagement, and video-product SQL practice.
Return to the complete interview preparation experience.