Skip to content

Intermediate SQL

Here you can access every table used in the course. To access each table, you will need to specify the cinema schema in your queries (e.g., cinema.reviews for the reviews table.

Style guides

Using the 'River' format style

SELECT name, breed, location FROM chickens WHERE continent = "Asia";

SELECT name, brd AS breed, loc AS location FROM chickens WHERE continent = "Asia";

One developer recommended this approach because modern browsers color code - but here is an example of where this does not work:

select name, brd as breed, loc as location from chickens where continent = "Asia";

Course Challenges

Spinner
DataFrameas
df
variable
-- Add your own queries here
SELECT *
FROM cinema.reviews
LIMIT 5
Spinner
DataFrameas
df
variable
SELECT *
FROM cinema.films
LIMIT 5

Explore Datasets

Use the descriptions, films, people, reviews, and roles tables to explore the data and practice your skills!

  • Which titles in the reviews table have an IMDB score higher than 8.5?
  • Select all titles from Germany released after 2010 from the films table.
  • Calculate a count of all movies by country using the films table.

Top 5 Rated Films

Spinner
DataFrameas
df
variable
SELECT r.film_id, f.title, r.imdb_score
FROM cinema.reviews AS r
    INNER JOIN cinema.films as f
        ON r.film_id = f.id
WHERE imdb_score > 8.5
ORDER BY imdb_score DESC
LIMIT 5;

German Film Leaders

Spinner
DataFrameas
df
variable
  SELECT f.title, f.gross
    FROM cinema.films AS f
   WHERE country = 'Germany'
          AND release_year > 2010
          AND gross IS NOT NULL
ORDER BY f.gross DESC;

Top 5 Countries

Spinner
DataFrameas
df
variable
   SELECT f.country, COUNT(f.country) AS total
    FROM cinema.films AS f
GROUP BY f.country
ORDER BY total DESC
   LIMIT 5;