-
Notifications
You must be signed in to change notification settings - Fork 1
/
33c.sql
51 lines (51 loc) · 1.54 KB
/
33c.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
41
42
43
44
45
46
47
48
49
50
51
SELECT min(cn1.name) AS first_company,
min(cn2.name) AS second_company,
min(mi_idx1.info) AS first_rating,
min(mi_idx2.info) AS second_rating,
min(t1.title) AS first_movie,
min(t2.title) AS second_movie
FROM company_name AS cn1,
company_name AS cn2,
info_type AS it1,
info_type AS it2,
kind_type AS kt1,
kind_type AS kt2,
link_type AS lt,
movie_companies AS mc1,
movie_companies AS mc2,
movie_info_idx AS mi_idx1,
movie_info_idx AS mi_idx2,
movie_link AS ml,
title AS t1,
title AS t2
WHERE cn1.country_code != '[us]'
AND it1.info = 'rating'
AND it2.info = 'rating'
AND kt1.kind in ('tv series',
'episode')
AND kt2.kind in ('tv series',
'episode')
AND lt.link in ('sequel',
'follows',
'followed by')
AND mi_idx2.info < '3.5'
AND t2.production_year BETWEEN 2000 AND 2010
AND lt.id = ml.link_type_id
AND t1.id = ml.movie_id
AND t2.id = ml.linked_movie_id
AND it1.id = mi_idx1.info_type_id
AND t1.id = mi_idx1.movie_id
AND kt1.id = t1.kind_id
AND cn1.id = mc1.company_id
AND t1.id = mc1.movie_id
AND ml.movie_id = mi_idx1.movie_id
AND ml.movie_id = mc1.movie_id
AND mi_idx1.movie_id = mc1.movie_id
AND it2.id = mi_idx2.info_type_id
AND t2.id = mi_idx2.movie_id
AND kt2.id = t2.kind_id
AND cn2.id = mc2.company_id
AND t2.id = mc2.movie_id
AND ml.linked_movie_id = mi_idx2.movie_id
AND ml.linked_movie_id = mc2.movie_id
AND mi_idx2.movie_id = mc2.movie_id;