-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpart2_neftlix_db_postgre.sql
More file actions
74 lines (45 loc) · 1.15 KB
/
part2_neftlix_db_postgre.sql
File metadata and controls
74 lines (45 loc) · 1.15 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- Netflix db project (part2)
SELECT * FROM netflix;
-- task 11: List All Movies that are Documentaries.
SELECT * FROM netflix
WHERE
listed_in LIKE '%Documentaries%';
-- task 12: Find All Content Without a Director
SELECT * FROM netflix
WHERE director is NULL;
-- task 13: Find How Many Movies Actor 'Salman Khan' Appeared in the Last 10 Years
SELECT* FROM netflix
WHERE
casts ILIKE '%Salman Khan%'
AND
release_year > EXTRACT(YEAR FROM CURRENT_DATE) - 10;
-- task 14: Find the Top 10 Actors Who Have Appeared in the Highest Number of Movies Produced in India
SELECT
UNNEST(STRING_TO_ARRAY(casts, ',')) as actors,
COUNT(*) as total_content
FROM netflix
WHERE country ILIKE '%India%'
GROUP BY 1
ORDER BY 2 DESC
LIMIT 10
-- task 15: Categorise Content Based on the Presence of 'Kill' and 'Violence' Keywords
WITH new_table
AS
(
SELECT
*,
CASE
WHEN
description ILIKE '%Kill%' OR
description ILIKE '%Violence%' THEN 'bad_content'
ELSE 'good_content'
END category
FROM netflix
)
SELECT
category,
COUNT(*) as total_content
FROM new_table
GROUP BY 1
---- <<end of part 2>>
---- <<end of part 2>>