🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 8:

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.

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

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