Important! These are all exam-level problems. Do not attempt these problems without a solid foundation in the subject and use them for exam practice.
For the all questions on this page, we will be using the following table named movies.
Name | Rating | Company |
Inside Out | 10 | Pixar |
Cinderella | 8.2 | Disney |
Lion King | 10 | Disney |
Twilight | 2.0 | Disney |
Star Wars 7 | 10 | Disney |
Up | 10 | Disney |
1. Select the company and its maximum rating, along with how many movies this company has made.
select company, count(*), max(ratings) from moves GROUP BY company
"YOUR CODE HERE"
2. Write a query to select all movies for which at least 2 other movies have the same rating, and put them alphabetically. Write this query using absolutely no aggregation techniques.
with
groups(name , score , n) as (
select title , rating , 1 from movies union
select title , score , n+1 from groups , movies
where title > name and rating=score
)
select title from groups,movies
where n > 2 and ratings = score order by ratings;
"YOUR CODE HERE"