🚀 November has started! SQLtest.online stays free thanks to donations from people like you. Help us reach this month's goal early so the site keeps running without interruptions. Support now →
SQL code copied to buffer
Task 9:

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

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