Flight Records
Start Timer
0:00:00
Write a query to create a new table, named flight routes, that displays unique pairs of two locations.
Note: Duplicate pairs from the flights table, such as Dallas to Seattle and Seattle to Dallas, should have one entry in the flight routes table.
Schema
flights table
| Column | Type |
|---|---|
id |
INTEGER |
source_location |
VARCHAR |
destination_location |
VARCHAR |
Output:
| Column | Type |
|---|---|
destination_one |
VARCHAR |
destination_two |
VARCHAR |
Example
Input:
flights table
| id | source_location | destination_location |
|---|---|---|
| 1 | Seattle, WA | Dallas, TX |
| 2 | Dallas, TX | Seattle, WA |
| 3 | Seattle, WA | San Francisco, CA |
| 4 | San Francisco, CA | Dallas, TX |
| 5 | San Francisco, CA | Portland, OR |
| 6 | Seattle, WA | Dallas, TX |
| 7 | Portland, OR | San Francisco, CA |
| 8 | San Francisco, CA | Los Angeles, CA |
Output:
| destination_one | destination_two |
|---|---|
| Dallas, TX | Seattle, WA |
| Portland, OR | San Francisco, CA |
| San Francisco, CA | Seattle, WA |
| Dallas, TX | San Francisco, CA |
| Los Angeles, CA | San Francisco, CA |
.
.
.
.
.
.
.
.
.
Comments