🎯 Few days left this month Support SQLTest.online and help us keep SQL practice free for everyone. Donate today →
SQL code copied to buffer
Task 7:

Passenger Trip Analysis

DuckDB
Analyze the trip data from the yellow_tripdata table to gather insights based on the number of passengers. Your output should include the following columns:
- passenger_count: the number of passengers
- trip_count: the total number of trips for each passenger count
- average_distance: the average trip distance rounded to two decimal places
- median_distance: the median trip distance rounded to two decimal places
- distance_p90: the 90th percentile of trip distance rounded to two decimal places

Ensure that you filter for passenger_count values between 1 and 6 and exclude any trips with trip_distance as NULL. The results should be grouped by passenger_count and sorted in ascending order by this column.
Expected result Columns: 5 · Rows: 6
passenger_count trip_count average_distance median_distance distance_p90

Sample rows open after wrong checks: 0 of 2

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