⏳ 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 76:

Clean Trip Dataset

DuckDB
Prepare a cleaned trip dataset for further analysis. Keep only records with the following criteria:
- Records with specified timestamps
- tpep_dropoff_datetime is not earlier than tpep_pickup_datetime
- trip_distance is positive
- total_amount is nonnegative
- passenger_count is positive

Replace a missing payment_type with Unknown. Add trip duration in minutes and trip cost per mile. Return the first 100 cleaned records.
Expected result Columns: 8 · Rows: 100
tpep_pickup_datetime tpep_dropoff_datetime payment_type passenger_count trip_distance total_amount trip_duration_minutes amount_per_mile

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