-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsample_queries.hql
51 lines (34 loc) · 1.63 KB
/
sample_queries.hql
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
-- Average fire pay
select avg(TOTALSALARYBENEFITS) from firepay;
-- Average fireman pay
select avg(TOTALSALARYBENEFITS) from firepay where positioncode between 7300 and 7399;
-- Average police pay
select avg(TOTALSALARYBENEFITS) from policepay;
-- Average policeman pay
select avg(TOTALSALARYBENEFITS) from policepay where positioncode between 7500 and 7599;
-- Cost per second for fire
select * from totalFirePays;
-- Cost per second for police
select * from totalPolicePays;
-- Average time for fire calls
select avg(secondsoncall) from firecallscost;
-- Average time for police calls
select avg(secondsoncall) from policecallscost;
-- Average cost for Fire calls
select avg(totalCost) from firecallscost where paydesc = 'TotalFirePay';
-- Average cost for Firemen calls
select avg(totalCost) from firecallscost where paydesc = 'TotalFiremanPay';
-- Average cost for Reno Government for fire calls
select avg(totalCost) from firecallscost where paydesc = 'TotalRenoPay';
-- Average cost for Police calls
select avg(totalCost) from policecallscost where paydesc = 'TotalPolicePay';
-- Average cost for Policeman calls
select avg(totalCost) from policecallscost where paydesc = 'TotalPolicemanPay';
-- Average cost for Reno Government for police calls
select avg(totalCost) from policecallscost where paydesc = 'TotalRenoPay';
-- Average costs for fire calls broken down by station
select STATION, avg(totalCost) from firecallscost where paydesc = 'TotalFirePay' group by STATION;
-- Costliest fire call
select * from firecallscost order by totalCost DESC limit 1;
-- Costliest police call
select * from policecallscost order by totalCost DESC limit 1;