-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetflix Analytics
More file actions
29 lines (24 loc) · 1.12 KB
/
Netflix Analytics
File metadata and controls
29 lines (24 loc) · 1.12 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
#In this SQL code, I'm querying a database that's holding Netflix data to answer questions.
#The SQL dialect is PostgreSQL.
#1. How many movie titles are there in the database? (movies only, not tv shows)
SELECT count(*)
FROM "RodrigoBravo/Netflix"."netflix_titles_info"
WHERE type='Movie';
#2. When was the most recent batch of tv shows and/or movies added to the database?
SELECT MAX(date(date_added)) as newest_data_added
FROM "RodrigoBravo/Netflix"."netflix_titles_info";
#3. List all the movies and tv shows in alphabetical order.
SELECT title
FROM "RodrigoBravo/Netflix"."netflix_titles_info"
ORDER BY title asc;
#4. Who was the Director for the movie Nightbooks?
SELECT director
FROM "RodrigoBravo/Netflix"."netflix_titles_info" a
LEFT JOIN "RodrigoBravo/Netflix"."netflix_people" b
ON a.show_id = b.show_id
where a.title = 'Nightbooks'
#5. What is the oldest movie in the database and what year was it made?
SELECT title, release_year
FROM "RodrigoBravo/Netflix"."netflix_titles_info"
WHERE type='Movie'
AND release_year <= (SELECT MIN(release_year) FROM "RodrigoBravo/Netflix"."netflix_titles_info" WHERE type = 'Movie');