Second Longest Flight
Start Timer
0:00:00
Given a table of flights, extract the 2nd flight with the most duration between each pair of cities. Order the flights by the flight id ascending.
Note: For any cities X and Y, (source_location=X, destination_location=Y) and (source_location=Y, destination_location=X) are counted as the same pair of cities.
Note: If there are fewer than two flights between two cities, there is no 2nd longest flight.
Example:
Input:
flights table
| Column | Type |
|---|---|
id |
INTEGER |
destination_location |
VARCHAR |
source_location |
VARCHAR |
plane_id |
INTEGER |
flight_start |
DATETIME |
flight_end |
DATETIME |
Output:
| Column | Type |
|---|---|
id |
INTEGER |
destination_location |
VARCHAR |
source_location |
VARCHAR |
flight_start |
DATETIME |
flight_end |
DATETIME |
.
.
.
.
.
.
.
.
.
Comments