⏳ Last days of October! SQLtest.online is free thanks to donations, and we still need to reach this month's goal to keep the site running in November. Every donation counts. Support now →
SQL code copied to buffer
Task 21:

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
The query result will appear here. Ctrl+Enter - Run query