ExpertAnalytics Patterns50 points

What does surge pricing really do?

Regulators in several cities ask Zoomi to prove that surge pricing does not just push riders to give up. A request is surged when surge > 1 and normal when surge <= 1. A cancelled request is any trip whose status is not 'Completed'. The fare per kilometre uses completed trips only: the sum of fare_usd divided by the sum of distance_km for that group.

Task: per city (name) return normal_cancel_pct and surge_cancel_pct (cancelled requests as a percent of all requests in that group), normal_fare_per_km and surge_fare_per_km, and surge_premium_pct = 100 * (surge fare per km / normal fare per km - 1), computed from the unrounded values. Round every one of the five measures with ROUND(x, 2) and name the first column city. Sort by city A to Z.

The data you can query

Each table is shown with its column types and the first rows, so you can see exactly what the data looks like.

cities4 rows
id INTEGERname TEXTcountry TEXT
1DubaiUAE
2LahorePakistan
3SingaporeSingapore
4NairobiKenya
drivers8 rows
id INTEGERname TEXTcity_id INTEGERjoined_on TEXTvehicle_type TEXT
1Rashid Al Mansoori12025-09-18Economy
2Tariq Mehmood22026-02-05Economy
3Wei Jie Tan32025-09-08Comfort
4Samuel Kiptoo42025-11-12Economy
5Hassan Qureshi12025-12-20Economy
6Priya Raman22025-06-24Economy

Showing the first 6 of 8 rows.

riders32 rows
id INTEGERname TEXThome_city_id INTEGERsignup_date TEXT
1Ayesha Khan12026-03-09
2Bilal Okafor22026-02-26
3Chen Silva32026-03-12
4Diego Tanaka42026-03-30
5Elena Weber12026-06-04
6Farid Nguyen22026-05-23

Showing the first 6 of 32 rows.

trips548 rows
id INTEGERrider_id INTEGERdriver_id INTEGERcity_id INTEGERrequested_at TEXTstatus TEXTdistance_km REALfare_usd REALsurge REALrating INTEGER
11512026-04-06 08:23:01Completed46.915
24842026-04-06 10:42:25Completed13.19.441.255
33332026-04-06 13:24:49Completed3.55.5315
42222026-04-06 17:17:07Completed15.89.51.54
51112026-04-06 18:25:11Completed11.819.351.254
64842026-04-06 21:01:43Completed16.69.314

Showing the first 6 of 548 rows.

Your query runs on SQLite. Write a single SELECT; use LIMIT instead of TOP.