-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL9_Netflix.sql
More file actions
29 lines (24 loc) · 1.58 KB
/
Copy pathSQL9_Netflix.sql
File metadata and controls
29 lines (24 loc) · 1.58 KB
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
/*Find the genre of the person with the most number of oscar winnings.If there are more than one person with the same
number of oscar wins, return the first one in alphabetic order based on their name. Use the names as keys when joining
the tables.*/
CREATE TABLE nominee_information(name varchar(20), amg_person_id varchar(10), top_genre varchar(10), birthday datetime,
id int);
INSERT INTO nominee_information VALUES('Jennifer Lawrence','P562566','Drama','1990-08-15',755),
('Jonah Hill','P418718','Comedy','1983-12-20',747),('Anne Hathaway', 'P292630','Drama', '1982-11-12',744),
('Jennifer Hudson','P454405','Drama', '1981-09-12',742),('Rinko Kikuchi', 'P475244','Drama', '1981-01-06', 739);
CREATE TABLE oscar_nominees(year int, category varchar(30), nominee varchar(20), movie varchar(30), winner int, id int);
INSERT INTO oscar_nominees VALUES(2008,'actress in a leading role','Anne Hathaway','Rachel Getting Married',0,77),
(2012,'actress in a supporting role','Anne HathawayLes','Mis_rables',1,78),
(2006,'actress in a supporting role','Jennifer Hudson','Dreamgirls',1,711),
(2010,'actress in a leading role','Jennifer Lawrence','Winters Bone',1,717),
(2012,'actress in a leading role','Jennifer Lawrence','Silver Linings Playbook',1,718),
(2011,'actor in a supporting role','Jonah Hill','Moneyball',0,799),
(2006,'actress in a supporting role','Rinko Kikuchi','Babel',0,1253);
Select ni.name,ni.top_genre,count(o.winner) as no_of_oscar
from nominee_information ni
left join oscar_nominees o
on ni.name=o.nominee
where o.winner>0
group by ni.name,ni.top_genre
order by no_of_oscar desc
limit 1;