bot50 2024-03-28 12:43:10 +00:00
commit f52efbc54f
13 changed files with 77 additions and 0 deletions

3
1.sql Normal file
View File

@ -0,0 +1,3 @@
SELECT title
FROM movies
WHERE year=2008;

8
10.sql Normal file
View File

@ -0,0 +1,8 @@
SELECT DISTINCT name
FROM people
JOIN directors ON people.id = directors.person_id
WHERE movie_id IN (
SELECT movie_id
FROM ratings
WHERE rating >= 9.0
);

7
11.sql Normal file
View File

@ -0,0 +1,7 @@
SELECT title
FROM movies
JOIN ratings ON movies.id = ratings.movie_id
JOIN stars ON movies.id = stars.movie_id
JOIN people ON stars.person_id = people.id
WHERE name = 'Chadwick Boseman'
ORDER BY rating DESC LIMIT 5;

6
12.sql Normal file
View File

@ -0,0 +1,6 @@
SELECT movies.title FROM stars
JOIN movies ON stars.movie_id = movies.id
JOIN people ON stars.person_id = people.id
WHERE people.name IN ('Bradley Cooper', 'Jennifer Lawrence')
GROUP BY movies.title
HAVING COUNT(movies.title) = 2;

10
13.sql Normal file
View File

@ -0,0 +1,10 @@
SELECT DISTINCT(name)
FROM people
WHERE name IS NOT 'Kevin Bacon' AND id IN(
SELECT person_id FROM stars WHERE movie_id IN(
SELECT movie_id FROM stars WHERE person_id IN(
SELECT id FROM people WHERE name IS 'Kevin Bacon' and birth = 1958
)
)
)
;

3
2.sql Normal file
View File

@ -0,0 +1,3 @@
SELECT birth
FROM people
WHERE name='Emma Stone';

4
3.sql Normal file
View File

@ -0,0 +1,4 @@
SELECT title
FROM movies
WHERE year>=2018
ORDER BY title;

3
4.sql Normal file
View File

@ -0,0 +1,3 @@
SELECT COUNT(rating)
FROM ratings
WHERE rating=10;

4
5.sql Normal file
View File

@ -0,0 +1,4 @@
SELECT title, year
FROM movies
WHERE title LIKE 'Harry Potter%'
ORDER BY year;

7
6.sql Normal file
View File

@ -0,0 +1,7 @@
SELECT AVG(rating)
FROM ratings
WHERE movie_id IN (
SELECT id
FROM movies
WHERE year = 2012
);

5
7.sql Normal file
View File

@ -0,0 +1,5 @@
SELECT title, rating
FROM movies
JOIN ratings ON movies.id = ratings.movie_id
WHERE year = 2010
ORDER BY rating DESC, title;

8
8.sql Normal file
View File

@ -0,0 +1,8 @@
SELECT name
FROM people
JOIN stars ON people.id = stars.person_id
WHERE movie_id IN (
SELECT id
FROM movies
WHERE title = 'Toy Story'
);

9
9.sql Normal file
View File

@ -0,0 +1,9 @@
SELECT DISTINCT(name)
FROM people
JOIN stars ON people.id = stars.person_id
WHERE movie_id IN (
SELECT id
FROM movies
WHERE year = 2004
)
ORDER BY birth;