🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 63:

Longest Break Between Departures in Moscow

PostgreSQL
The ground staff of the three Moscow airports (DME, SVO, VKO) plans runway maintenance for August 15, 2017 (the times in the table are in UTC) and looks for the longest break between two consecutive scheduled departures at each airport.
For every airport, find this break in the flights table: the departure that starts it, the next departure that ends it and its length. Only departures of that day count.
Output the columns departure_airport, gap_start, gap_end and gap (an interval), one row per airport, sorted by departure_airport.
Expected result Columns: 4 · Rows: 3
departure_airport gap_start gap_end gap

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