New month, new goals. Your help keeps the project moving forward. 🖥️ Support sqltest →
SQL code copied to buffer
Task 58:

Zones with Unusually High Cost per Mile

DuckDB
Your goal is to analyze the trip costs from the yellow_tripdata table. You need to calculate the average amount per mile for each PULocationID that has at least 100 trips, and compare it to the overall average amount per mile. The output should include the following columns:
- PULocationID: The ID of the pickup location.
- trip_count: The total number of trips for that location.
- average_amount_per_mile: The average amount charged per mile, rounded to two decimal places.
- above_overall_percentage: The percentage by which the average amount per mile exceeds the overall average, rounded to two decimal places.

Sort the results by average_amount_per_mile in descending order.
Expected result Columns: 4 · Rows: 80
PULocationID trip_count average_amount_per_mile above_overall_percentage

Sample rows open after wrong checks: 0 of 2

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

Hi! Could we please enable some services and cookies to improve your experience and our website?

Privacy & Cookie Policy.