-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery-12.sql
47 lines (34 loc) · 1.03 KB
/
query-12.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* List the cities connected EXCLUSIVELY by Tuesday flights, meaning flights departing from or arriving at these cities only on Tuesdays. The list should have a single column. Avoid using JOIN. */
-- Lists all the cities that have flights departing or arriving
(
-- Lists cities that have flights departing
SELECT
FLIGHTS.DepartureCityName AS "City"
FROM
FLIGHTS
UNION
-- Lists cities that have flights arriving
SELECT
FLIGHTS.ArrivalCityName AS "City"
FROM
FLIGHTS
)
EXCEPT
-- Lists all the cities that have flights departing or arriving any day but Tuesday
(
-- Lists all the cities that have flights departing any day but Tuesday
SELECT
FLIGHTS.DepartureCityName AS "City"
FROM
FLIGHTS
WHERE
FLIGHTS.DayOfWeek <> 'TU'
UNION
-- -- Lists all the cities that have flights arriving any day but Tuesday
SELECT
FLIGHTS.ArrivalCityName AS "City"
FROM
FLIGHTS
WHERE
FLIGHTS.DayOfWeek <> 'TU'
);