Given a Flights table containing flight traffic data between airports, find the airport(s) with the most total traffic.
The airport with the most traffic is defined as the airport that has the largest total number of flights that either departed from or arrived at that airport.
If there are multiple airports tied for the most traffic, return all of them.
- Each row represents flights between two airports with the flight count
- An airport's total traffic = sum of all flights departing from it + sum of all flights arriving at it
- Return results in any order
Table Schema
| Column Name | Type | Description |
|---|---|---|
departure_airport
PK
|
int | ID of the departure airport |
arrival_airport
PK
|
int | ID of the arrival airport |
flights_count
|
int | Number of flights from departure to arrival airport |
Input & Output
| departure_airport | arrival_airport | flights_count |
|---|---|---|
| 1 | 2 | 150 |
| 2 | 1 | 100 |
| 2 | 3 | 200 |
| airport_id |
|---|
| 2 |
Airport traffic calculation: Airport 1 has 150 (departure) + 100 (arrival) = 250 total flights. Airport 2 has 100 + 200 (departures) + 150 (arrival) = 450 total flights. Airport 3 has 0 (departure) + 200 (arrival) = 200 total flights. Airport 2 has the highest traffic with 450 flights.
| departure_airport | arrival_airport | flights_count |
|---|---|---|
| 1 | 2 | 100 |
| 2 | 1 | 100 |
| 1 | 3 | 50 |
| 3 | 2 | 50 |
| airport_id |
|---|
| 1 |
| 2 |
Airport 1 has 100 + 50 (departures) + 100 (arrival) = 250 total flights. Airport 2 has 100 (departure) + 100 + 50 (arrivals) = 250 total flights. Airport 3 has 50 (departure) + 50 (arrival) = 100 total flights. Airports 1 and 2 are tied with 250 flights each, so both are returned.
Constraints
-
1 ≤ departure_airport, arrival_airport ≤ 1000 -
1 ≤ flights_count ≤ 10000 -
departure_airport ≠ arrival_airport