🚀 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 24:

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

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