Analyze Taxi Driver and Ride Metrics
Reported by candidates from TikTok's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this TikTok SQL question is treating the four ride tables like one table. They aren't. This one was reported in September 2026, and it asks for three metrics stacked into a single two-column result: average driver rating, percent of drivers with a second language, and ride success rate across rides_1 through rides_4. It looks like three easy queries. The trap is in the glue and the exact-match rules. If you blank on the structure during the live OA, StealthCoder runs invisibly as a safety net and hands you the shape of the query.
The problem
You are given one table of taxi drivers and four partitions of ride data. Produce three summary metrics over the complete data set. Return the average value of drivers.rating with insight_type equal to average_driver_rating. Return the percentage of drivers whose second_language is not exactly no with insight_type equal to percentage_drivers_with_second_language. Combine rides_1 through rides_4, then return the percentage of rides whose status is exactly Success with insight_type equal to ride_success_rate. Return a two-column table named by the result contract. Each row corresponds to one task above, in the same order. Tables drivers: driver_id PK (Integer), age (Integer), second_language (Text), rating (Decimal) rides_1: ride_id PK (Integer), driver_id (Integer), passenger_id (Integer), date (Text), status (Text) rides_2: ride_id PK (Integer), driver_id (Integer), passenger_id (Integer), date (Text), status (Text) rides_3: ride_id PK (Integer), driver_id (Integer), passenger_id (Integer), date (Text), status (Text) rides_4: ride_id PK (Integer), driver_id (Integer), passenger_id (Integer), date (Text), status (Text) Constraints There is at least one driver and at least one ride across the four ride partitions. driver_id and ride_id values are unique identifiers in their source files. Every ride references a driver in drivers. second_language uses the exact value no when a driver has no second language. status is one of Rejected by the driver, Cancelled by the passenger, or Success. Percentages use the 0-to-100 scale. Numeric results are accepted within 0.01 of the expected value.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is UNION ALL, then aggregate. Query one is AVG(rating) from drivers. Query two is 100.0 * SUM(CASE WHEN second_language <> 'no' THEN 1 ELSE 0 END) / COUNT(*) from drivers. Query three first stacks rides_1 to rides_4 with UNION ALL in a subquery or CTE, then computes 100.0 * SUM(CASE WHEN status = 'Success' THEN 1 ELSE 0 END) / COUNT(*). Use UNION ALL, never UNION, because dedup could drop legitimate rows. Use 100.0, not 100, or integer division will give you 0. Match 'no' and 'Success' exactly, since the spec says exact. Then UNION ALL the three result rows in the stated order, with insight_type as the first column and the value as the second. If you blank live, StealthCoder is the hedge that gives you this skeleton.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Analyze Taxi Driver and Ride Metrics cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass TikTok's OA.
TikTok reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Analyze Taxi Driver and Ride Metrics FAQ
What's the trick in the TikTok taxi driver metrics question?+
Stack the four ride tables with UNION ALL before computing the success rate. Then watch integer division. Multiply by 100.0, not 100, so the percentage doesn't truncate to 0. The rest is three simple aggregates glued into one result.
Why UNION ALL and not UNION?+
UNION removes duplicate rows, which can silently change your count. Ride IDs are unique per source file, but rows with identical values across partitions shouldn't be collapsed. UNION ALL keeps every ride, so your denominator is correct and the success rate lands within the 0.01 tolerance.
How do I handle second_language correctly?+
The spec says no language is stored as the exact value no. Count drivers where second_language <> 'no' and divide by total drivers, times 100.0. Don't use LIKE or lowercasing tricks that change the meaning, and don't count NULLs as a language unless the data forces it.
How do I combine three metrics into one result table?+
Write three SELECT statements, each returning a literal insight_type and one numeric value. Join them with UNION ALL in the order the problem lists: rating, second language percentage, then ride success rate. Keep column names and order consistent across all three.
How do I prepare for this in 48 hours?+
Practice conditional aggregation with SUM(CASE WHEN...) and percentage math with 100.0. Rehearse UNION ALL on multiple partitions and stacking several result rows. That covers nearly all of this question. Check your output against the exact value rules before submitting.