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.

Take Notes

Add notes about the concepts you've learned and SQL cells with queries you want to keep.

Add your notes here

Spinner
DataFrameas
df
variable
-- Add your own queries here
SELECT *
FROM cinema.reviews
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.
Spinner
DataFrameas
df
variable
SELECT
COUNT(name) AS count_names, 
COUNT(birthdate) AS count_birthdates
FROM cinema.people
LIMIT 5;
Spinner
DataFrameas
df
variable
SELECT
COUNT(DISTINCT birthdate) AS count_distinct_birthdates
FROM cinema.people
LIMIT 5;

Here is a query counting film_id. Select the answer below that correctly describes what the query will return.

COUNT(field_name) returns the number of records containing a value in a field. In this example, that field is film_id.

Spinner
DataFrameas
df
variable
SELECT COUNT(film_id) AS count_film_id
FROM cinema.reviews;

COUNT(*) tells you how many records are in a table. However, if you want to count the number of non-missing values in a particular field, you can call COUNT() on just that field.

Count the number of records in the people table, aliasing the result as count_records.

Spinner
DataFrameas
df
variable
-- Count the number of records in the people table
SELECT COUNT(people) AS count_records
FROM cinema.people;
Spinner
DataFrameas
df
variable
-- Count the number of birthdates in the people table
-- SELECT COUNT(birthdate) AS count_birthdate,
-- FROM cinema.people;

-- Count the number of birthdates in the people table
SELECT COUNT(birthdate) AS count_birthdate
FROM cinema.people;

Count the languages and countries in the films table; alias as count_languages and count_countries.

Spinner
DataFrameas
df
variable
-- Count the languages and countries represented in the films table
SELECT 
COUNT(language) AS count_languages, 
COUNT(country) AS count_countries
FROM cinema.films;