runtime
104 / 139

task Monthly / weekly buckets · medium

Predict: dates across midnight

Predict the arrival date and whether it differs from the flight date for each sample flight.

what to return

Columns
flight_idflight_datearrival_dateovernight in this order
Rows
in the order asked
Watch for
Use only the sample rows shown. NULL is not zero or empty text. Keep duplicate rows.
Skill
Reason about the exact result of a fixed SQL query. Refresher: Date boundaries & monthly buckets →

data you can query

U.S. Flights dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.

overnight_sample4 columns · 2 rows
flight_idflight_datedatescheduled_departuredate & timescheduled_arrivaldate & time
196002025-01-152025-01-15 22:492025-01-15 23:59
196162025-01-152025-01-15 23:302025-01-16 07:47
flight_id
19600
flight_datedate
2025-01-15
scheduled_departuredate & time
2025-01-15 22:49
scheduled_arrivaldate & time
2025-01-15 23:59
flight_id
19616
flight_datedate
2025-01-15
scheduled_departuredate & time
2025-01-15 23:30
scheduled_arrivaldate & time
2025-01-16 07:47

all 2 rows

predict.sql
SELECT
  flight_id,
  flight_date,
  date(scheduled_arrival) AS arrival_date,
  date(scheduled_arrival) > flight_date AS overnight
FROM overnight_sample
ORDER BY flight_id
Read the query · predict its result
SELECT flight_id, flight_date, date(scheduled_arrival) AS arrival_date, date(scheduled_arrival) > flight_date AS overnight FROM overnight_sample ORDER BY flight_id

Look at the sample tables and SQL. Enter the rows you think the query returns, in this column order: flight_id, flight_date, arrival_date, overnight. Put each row in square brackets, then wrap all rows in another pair of brackets (JSON format). For example, [[1,null,null,null]] is one row with 4 values. Replace these with your predicted values. Use numbers without quotes, text in double quotes, and null for SQL NULL. Keep repeated rows. Use [] for no rows. Keep rows in the order specified by ORDER BY.

Hints and the answer are always available. Using them counts the question as solved with help.

Predict: dates across midnight — SQL practice · Runtime