Keep SQLtest alive: Help cover this month's $100 server costs to keep all lessons and the SQL playground online. Support the project →
SQL code copied to buffer
Task 60:

Trip Cost Quantiles

DuckDB
Write a query to analyze the payment types used in taxi trips. Your output should include the following columns:
- payment_type: the type of payment used
- trip_count: the total number of trips for each payment type
- approximate_median_amount: the approximate median total amount for each payment type, rounded to two decimal places
- approximate_p90_amount: the approximate 90th percentile total amount for each payment type, rounded to two decimal places

Ensure that you only include records where both payment_type and total_amount are not null. The results should be grouped by payment_type and sorted in ascending order by this column.
Expected result Columns: 4 · Rows: 5
payment_type trip_count approximate_median_amount approximate_p90_amount

Sample rows open after wrong checks: 0 of 3

Write your query below and click "Check it!". Tables are described in the right pane.

The query result will appear here. Ctrl+Enter - Run query