-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetflixData.sql
More file actions
58 lines (45 loc) · 1.63 KB
/
netflixData.sql
File metadata and controls
58 lines (45 loc) · 1.63 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
/*
PostgreSQL query
Netflix Data
- In this SQL code, I'm querying a database that's holding Netflix data to answer questions about the data.
*/
/*JOIN two tables*/
SELECT
peoples.show_id,
peoples.director,
titles.title,
titles.type
FROM "CharlotteChaze/BreakIntoTech"."netflix_people" peoples
LEFT JOIN "CharlotteChaze/BreakIntoTech"."netflix_titles_info" titles
ON titles.show_id = peoples.show_id
/*How many movie titles are there in the database?
(movies only, not tv shows)*/
SELECT count(*)
FROM "CharlotteChaze/BreakIntoTech"."netflix_titles_info"
WHERE type='Movie';
/*When was the most recent batch of tv shows and/or movies added to the database?*/
SELECT MAX(DATE(date_added)) AS recent_batch
FROM "CharlotteChaze/BreakIntoTech"."netflix_titles_info"
/* List all the movies and tv shows in alphabetical order.*/
SELECT title
FROM "CharlotteChaze/BreakIntoTech"."netflix_titles_info"
ORDER BY title
/*Who was the Director for the movie Bright Star?*/
SELECT director,type,peoples.cast
FROM "CharlotteChaze/BreakIntoTech"."netflix_people" peoples
LEFT JOIN "CharlotteChaze/BreakIntoTech"."netflix_titles_info" titles
ON titles.show_id = peoples.show_id
WHERE titles.title = 'Bright Star'
/*What is the oldest movie in the database and what year was it made?*/
select title, release_year
FROM "CharlotteChaze/BreakIntoTech"."netflix_titles_info"
WHERE type='Movie'
ORDER BY release_year asc
LIMIT 1;
SELECT title, release_year
FROM "CharlotteChaze/BreakIntoTech"."netflix_titles_info"
WHERE type = 'Movie'
AND release_year <=
(SELECT MIN(release_year)
FROM "CharlotteChaze/BreakIntoTech"."netflix_titles_info"
WHERE type = 'Movie');