Skip to content

Commit 568018d

Browse files
authored
Create Flight Records
1 parent f5a9b73 commit 568018d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Flight Records

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'''
2+
Write a query to create a new table, named flight routes, that displays unique pairs of two locations.
3+
'''
4+
5+
with grouped_pairs as(
6+
select
7+
8+
9+
case when f1.source_location< f1.destination_location then f1.source_location else f1.destination_location end as destination_one,
10+
case when f1.source_location > f1.destination_location then f1.source_location else f1.destination_location end as destination_two
11+
12+
from flights f1)
13+
14+
15+
16+
select destination_one, destination_two from grouped_pairs
17+
18+
group by 1,2

0 commit comments

Comments
 (0)