-
Notifications
You must be signed in to change notification settings - Fork 0
/
task3a-hive.sql
29 lines (27 loc) · 898 Bytes
/
task3a-hive.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
SELECT
pre.maxawards, master.firstname, master.lastname, master.birthyear, master.birthmon, master.birthday, master.birthcountry
FROM
(SELECT max.maxawards as maxawards, awardscounts_2.coachid as coachid
FROM
(SELECT count(award) as num_awards,coachid
FROM awardscoaches
GROUP BY (coachid)
) awardscounts_2
JOIN
(SELECT MAX(awardscounts.num_awards) as maxawards
FROM
(SELECT count(award) as num_awards,coachid
FROM awardscoaches
GROUP BY (coachid)
) awardscounts
) max
ON (awardscounts_2.num_awards = max.maxawards)
) pre
JOIN master
ON ( pre.coachid = master.coachid)
;
--Analysis
ANALYZE TABLE awardscoaches COMPUTE STATISTICS;
ANALYZE TABLE awardscoaches COMPUTE STATISTICS FOR COLUMNS coachid, award;
ANALYZE TABLE master COMPUTE STATISTICS;
ANALYZE TABLE master COMPUTE STATISTICS FOR COLUMNS firstname, lastname, birthyear, birthmon, birthday, birthcountry;