-
Notifications
You must be signed in to change notification settings - Fork 0
/
aviation.sql
78 lines (37 loc) · 1.63 KB
/
aviation.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
select * from airline;
select * from airline_1;
select count(*) from airline where TailNum="N953FR" ;
select count(*) from airline_1 where TailNum = "-" ;
-- KPI 1 --
--------- WeekDay Vs WeekEnd Total Flights ----------
select weekdayend, count(tailnum) as "Total Flights"
from airline
group by weekdayend ;
-- KPI 2 --
--------- Week-wise Arrival and Departure Flights from Manchester , NH ----------
SELECT origincityname, WEEKNUM as "Week Number",count(*) as "Total_Flights"
FROM airline -- Departure Flights --
where origincityname="Manchester, NH"
group by WEEKNUM
order by total_flights desc ;
SELECT DestCityName, WEEKNUM as "Week Number",COUNT(AirlineID) as "Total_Flights"
FROM airline -- Arrival Flights --
where DestCityName="Manchester, NH"
group by WEEKNUM
order by total_flights desc ;
-- KPI 3 --
--------- Honolulu,HI --> Total Cancelled Flights ----------
select a.origincityname,sum(b.Cancelled) AS "Cancelled Flights"
from airline as a
left join
airline_1 as b using(index1)
where a.origincityname= "Honolulu, HI"
group by a.OriginCityName ;
-- KPI 4 --
--------- TailNumber N190AA --> Total Distance ----------
select a.TAILNUM,AirTime,flightdate,sum(b.Distance) AS "Total Distance"
from airline as a
LEFT join
airline_1 as b using(INDEX1)
where a.tailnum= "N190AA" AND b.AirTime=50 AND a.flightdate="2017-01-01"
group by a.tailnum ;