runtime
133 / 139

task Missing relationships / anti-joins · medium

Routes flown in one direction only

Return origin and destination for routes whose reverse (destination → origin) does not exist in routes.

what to return

Columns
origindestination in this order
Rows
46 rows · any order
Skill
Find relationships that are not symmetric. Refresher: Self-joins & referral relationships →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result46 rows · any order
origindestination
AUSCHS
AUSSJU
BNABUF

first 3 of 46 rows

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.

routes4 columns · 5,436 rows
route_idnumber · unique idorigintext · links to airportsdestinationtext · links to airportsdistance_milesnumber
1ABECLT481
2ABEFLL1041
3ABEMCO906
4ABEMLB914
5ABEMYR518
6ABEPGD1018
route_idnumber · unique id
1
origintext · links to airports
ABE
destinationtext · links to airports
CLT
distance_milesnumber
481
route_idnumber · unique id
2
origintext · links to airports
ABE
destinationtext · links to airports
FLL
distance_milesnumber
1041
route_idnumber · unique id
3
origintext · links to airports
ABE
destinationtext · links to airports
MCO
distance_milesnumber
906
route_idnumber · unique id
4
origintext · links to airports
ABE
destinationtext · links to airports
MLB
distance_milesnumber
914
route_idnumber · unique id
5
origintext · links to airports
ABE
destinationtext · links to airports
MYR
distance_milesnumber
518
route_idnumber · unique id
6
origintext · links to airports
ABE
destinationtext · links to airports
PGD
distance_milesnumber
1018

first 6 of 5,436 rows · your queries use all of them

solution.sql
 

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

Routes flown in one direction only — SQL practice · Runtime