-
Notifications
You must be signed in to change notification settings - Fork 2
/
queries.sql
40 lines (39 loc) · 1.48 KB
/
queries.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
--Squawk Code Count
select distinct ft.squawk, count(distinct fs.flight_id)
from flight_summary fs, flight_trajectory ft, aircraft_metadata am
where fs.icao24 = ft.icao24
and am.icao24 = ft.icao24
--and ft.squawk = 7700
group by ft.squawk
order by count(distinct fs.flight_id) DESC
****************************************************
--Tweet Problem Count
select distinct fs.tweet_problem, count(distinct fs.flight_id)
from flight_summary fs, flight_trajectory ft, aircraft_metadata am
where fs.icao24 = ft.icao24
and am.icao24 = ft.icao24
--and ft.squawk = 7700
group by fs.tweet_problem
******************************************
select distinct fs.avh_problem, count(distinct fs.flight_id)
from flight_summary fs, flight_trajectory ft, aircraft_metadata am
where fs.icao24 = ft.icao24
and am.icao24 = ft.icao24
--and ft.squawk = 7700
group by fs.avh_problem
*************************************
--result count
select distinct fs.tweet_result, count(distinct fs.flight_id)
from flight_summary fs, flight_trajectory ft, aircraft_metadata am
where fs.icao24 = ft.icao24
and am.icao24 = ft.icao24
--and ft.squawk = 7700
group by fs.tweet_result
***********************************************
--Manufacturer count
select distinct substr(am.manufacturername,1,6), fs.tweet_result, count(distinct fs.flight_id)
from flight_summary fs, flight_trajectory ft, aircraft_metadata am
where fs.icao24 = ft.icao24
and am.icao24 = ft.icao24
--and ft.squawk = 7700
group by substr(am.manufacturername,1,6),fs.tweet_result