-
Notifications
You must be signed in to change notification settings - Fork 0
/
movies db script 1.sql
72 lines (63 loc) · 1.89 KB
/
movies db script 1.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--SELECT * FROM MovFinLang;
-- 1. ROI
SELECT
movie_title "Movie",
CAST((revenue_USD_millions - budget_USD_millions) / budget_USD_millions * 100 AS DECIMAL(10,2)) "Percent ROI"
FROM MovFinLang
ORDER BY [Percent ROI] DESC;
-- 2. Average IMDB Ratings
SELECT
CAST (AVG (imdb_rating) AS DECIMAL (10, 2)) "AVG Ratings"
FROM MovFinLang;
-- 3. Movie counts grouped by industries, languages, and years
SELECT
DISTINCT (industry),
language_list "languages",
release_year "release years",
COUNT(movie_title) "Movie Count"
FROM
MovFinLang
GROUP BY
industry,
language_list,
release_year
ORDER BY [Movie Count] DESC;
-- 4. Total revenue and budget by industry.
SELECT
industry, CAST (SUM(budget_INR_millions) AS DECIMAL (10, 2)) "Budget (₹ Mln)"
FROM MovFinLang
GROUP BY industry;
-- 5. Average IMDb rating per industry.
SELECT
industry,CAST (AVG (imdb_rating) AS DECIMAL (10, 2)) "Avg Ratings"
FROM MovFinLang
GROUP BY industry;
-- 6. Movie count per language.
SELECT
language_list AS "Languages",
COUNT(movie_title) AS "Movies"
FROM
MovFinLang
GROUP BY
language_list;
-- 7. Average budget & revenue per language.
SELECT
language_list "Language",
CAST (AVG (budget_INR_millions) AS DECIMAL (10, 2)) "Avg Budget (₹ Mln)",
CAST (AVG (revenue_INR_millions) AS DECIMAL (10, 2)) "Avg Revenue (₹ Mln)"
FROM MovFinLang
GROUP BY language_list;
-- 8. Total revenue and average IMDb ratings for each studio.
SELECT
studio "Studio",
CAST (SUM (revenue_INR_millions) AS DECIMAL (10, 2)) "Total Revenue (₹ Mln)",
CAST (SUM (revenue_USD_millions) AS DECIMAL (10, 2)) "Total Revenue ($ Mln)",
CAST (AVG (imdb_rating) AS DECIMAL (10, 2)) "Avg Ratings"
FROM MovFinLang
GROUP BY studio;
-- 9. Number of movies produced by each studio.
SELECT
studio "Studio",
COUNT (movie_title) "Movies"
FROM MovFinLang
GROUP BY studio;