NYC Yellow Taxi dataset (DuckDB): the yellow_tripdata table and SQL exercises
yellow_tripdata holds the New York City yellow taxi trips of January 2024, almost 3 million rows, loaded into DuckDB for analytical SQL. On SQLtest.online you can query it right in your browser: solve exercises with automatic checking and run your own queries in the playground, with nothing to install.
- 1 table, 19 columns
- 2,964,624 trips
- January 2024
- 19 SQL exercises
What is NYC Yellow Taxi
The data comes from the trip records that the New York City Taxi and Limousine Commission (TLC) publishes every month. Each row is one trip: pickup and drop-off time, distance, number of passengers, pickup and drop-off zones, payment type and every part of the fare.
DuckDB is an embedded analytical database with columnar storage, so aggregations over millions of rows run in a fraction of a second. That makes the dataset a good place to practice real analytics: time series, distributions, percentiles and data cleaning.
What's inside
All the data is in one table, yellow_tripdata. Every column allows NULL, and there are no keys or constraints. PULocationID and DOLocationID are TLC taxi zone numbers. A few trips have pickup times outside January 2024 and some have zero or negative amounts: real data needs cleaning, and some exercises are about exactly that.
How much data the tables hold:
| Table | Rows | Contents |
|---|---|---|
| yellow_tripdata | 2,964,624 | yellow taxi trips |
Table structure
Click a table to see its columns, a sample row and its keys.
yellow_tripdata Table
- VendorID taxi service provider identifier.
- tpep_pickup_datetime passenger pickup date and time.
- tpep_dropoff_datetime passenger drop-off date and time.
- passenger_count number of passengers.
- trip_distance trip distance.
- RatecodeID rate code identifier.
- store_and_fwd_flag flag indicating that trip data was stored before forwarding.
- PULocationID pickup zone identifier.
- DOLocationID drop-off zone identifier.
- payment_type payment method identifier.
- fare_amount trip fare excluding additional charges.
- extra additional charges.
- mta_tax MTA tax.
- tip_amount tip amount.
- tolls_amount toll charges.
- improvement_surcharge transportation system improvement surcharge.
- total_amount total trip cost.
- congestion_surcharge congestion surcharge.
- Airport_fee airport fee.
| Column name | Type | NULL | Key | Default | Extra |
|---|---|---|---|---|---|
| VendorID | INTEGER | YES | [null] | [null] | [null] |
| tpep_pickup_datetime | TIMESTAMP | YES | [null] | [null] | [null] |
| tpep_dropoff_datetime | TIMESTAMP | YES | [null] | [null] | [null] |
| passenger_count | BIGINT | YES | [null] | [null] | [null] |
| trip_distance | DOUBLE | YES | [null] | [null] | [null] |
| RatecodeID | BIGINT | YES | [null] | [null] | [null] |
| store_and_fwd_flag | VARCHAR | YES | [null] | [null] | [null] |
| PULocationID | INTEGER | YES | [null] | [null] | [null] |
| DOLocationID | INTEGER | YES | [null] | [null] | [null] |
| payment_type | BIGINT | YES | [null] | [null] | [null] |
| fare_amount | DOUBLE | YES | [null] | [null] | [null] |
| extra | DOUBLE | YES | [null] | [null] | [null] |
| mta_tax | DOUBLE | YES | [null] | [null] | [null] |
| tip_amount | DOUBLE | YES | [null] | [null] | [null] |
| tolls_amount | DOUBLE | YES | [null] | [null] | [null] |
| improvement_surcharge | DOUBLE | YES | [null] | [null] | [null] |
| total_amount | DOUBLE | YES | [null] | [null] | [null] |
| congestion_surcharge | DOUBLE | YES | [null] | [null] | [null] |
| Airport_fee | DOUBLE | YES | [null] | [null] | [null] |
Sample queries
These queries show how the data is connected. Copy any of them and run it in the playground.
Trip duration: DuckDB's date_diff between pickup and drop-off.
SELECT tpep_pickup_datetime,
date_diff('minute', tpep_pickup_datetime, tpep_dropoff_datetime) AS minutes,
trip_distance, total_amount
FROM yellow_tripdata
WHERE tpep_pickup_datetime >= '2024-01-01'
ORDER BY tpep_pickup_datetime
LIMIT 3;
| tpep_pickup_datetime | minutes | trip_distance | total_amount |
|---|---|---|---|
| 2024-01-01 00:00:00 | 2 | 0.3 | 11.25 |
| 2024-01-01 00:00:02 | 4 | 1.57 | 16.32 |
| 2024-01-01 00:00:03 | 3 | 0.5 | 7.6 |
A quick count: DuckDB's GROUP BY ALL groups by every non-aggregated column.
SELECT store_and_fwd_flag, COUNT(*) AS trips
FROM yellow_tripdata
GROUP BY ALL
ORDER BY trips DESC;
| store_and_fwd_flag | trips |
|---|---|
| N | 2813126 |
| NULL | 140162 |
| Y | 11336 |
SQL exercises by topic
There are 19 exercises on this dataset, from overall statistics to time series and data quality checks. Solutions are checked automatically on a real DuckDB. The number on the right is how many exercises a topic has; the colored dots show its difficulty range.
Where to start
The first exercises on the NYC Yellow Taxi database:
- Overall Trip Statistics
- Average Fare by Payment Type
- Longest Trips
- Monthly Statistics
- Most Popular Pickup Zones
- Compare Tips by Payment Type
- Top Pickup Zones by Month
- Passenger Trip Analysis
- Trip Efficiency by Distance Range
- Zones with Unusually High Cost per Mile
All NYC Yellow Taxi exercises →
FAQ
Do I need to install DuckDB to use this dataset?
No. The exercises and the playground on SQLtest.online run your queries on our servers, so a browser is all you need. In the playground, choose DuckDB.
Where does the data come from?
From the NYC Taxi and Limousine Commission trip record data, which is published monthly as Parquet files. This copy holds the yellow taxi trips of January 2024.
How is DuckDB SQL different?
It is close to PostgreSQL, with extras for analytics such as GROUP BY ALL, QUALIFY, date_diff and quantile functions.