-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql4.8.sql
More file actions
55 lines (39 loc) · 1.13 KB
/
sql4.8.sql
File metadata and controls
55 lines (39 loc) · 1.13 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
USE moviesdb;
SELECT MAX(imdb_rating)
FROM movies
WHERE industry = 'Bollywood';
SELECT MIN(imdb_rating)
FROM movies
WHERE industry = 'Bollywood';
SELECT ROUND(AVG(imdb_rating), 2)
FROM movies
WHERE studio = 'Marvel Studios';
SELECT MIN(imdb_rating) as min_rating, MAX(imdb_rating) as max_rating, ROUND(AVG(imdb_rating), 2) AS avg_rating
FROM movies
WHERE studio = 'Marvel Studios';
SELECT industry, COUNT(*)
FROM movies
GROUP BY industry;
SELECT studio, COUNT(*) as count
FROM movies
GROUP BY studio
ORDER BY count DESC;
SELECT studio, count(studio) as count, round(avg(imdb_rating), 1) as avg_rating
FROM movies
WHERE studio != ""
GROUP BY studio
ORDER BY avg_rating DESC;
-- 1. How many movies were released between 2015 and 2022
SELECT count(*)
FROM movies
WHERE release_year between 2015 AND 2022;
-- 2. Print the max and min movie release year
SELECT MAX(release_year)
FROM movies;
SELECT MIN(release_year)
FROM movies;
-- 3. Print each year along with the number of movies released in that year, starting from the most recent year
SELECT release_year, COUNT(*) as count
FROM movies
GROUP BY release_year
ORDER BY release_year DESC;