forked from viktorleis/job
-
Notifications
You must be signed in to change notification settings - Fork 0
/
12c.sql
31 lines (31 loc) · 923 Bytes
/
12c.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
SELECT min(cn.name) AS movie_company,
min(mi_idx.info) AS rating,
min(t.title) AS mainstream_movie
FROM company_name AS cn,
company_type AS ct,
info_type AS it1,
info_type AS it2,
movie_companies AS mc,
movie_info AS mi,
movie_info_idx AS mi_idx,
title AS t
WHERE cn.country_code = '[us]'
AND ct.kind = 'production companies'
AND it1.info = 'genres'
AND it2.info = 'rating'
AND mi.info in ('Drama',
'Horror',
'Western',
'Family')
AND mi_idx.info > '7.0'
AND t.production_year BETWEEN 2000 AND 2010
AND t.id = mi.movie_id
AND t.id = mi_idx.movie_id
AND mi.info_type_id = it1.id
AND mi_idx.info_type_id = it2.id
AND t.id = mc.movie_id
AND ct.id = mc.company_type_id
AND cn.id = mc.company_id
AND mc.movie_id = mi.movie_id
AND mc.movie_id = mi_idx.movie_id
AND mi.movie_id = mi_idx.movie_id;