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.

CONTAR NUM de record con 100k o mas

Spinner
DataFrameas
df
variable
-- Count the records with at least 100,000 votes
SELECT COUNT(*) AS films_over_100K_votes
FROM reviews
WHERE num_votes >= 100000;

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.

or and BETWEEN

Spinner
DataFrameas
df
variable
SELECT title, release_year
FROM films
WHERE (release_year = 1990 OR release_year = 1999)
-- Add a filter to see only English or Spanish-language films
	AND (language = 'English' OR language = 'Spanish');

para texto LIKE /NOT LIKE/ IN % MATCH ZERO, ONE OR MANY CHARACTERS/ _ MATCH A SINGLE

Time for a little challenge. So far, your SQL vocabulary from this course includes COUNT(), DISTINCT, LIMIT, WHERE, OR, AND, BETWEEN, LIKE, NOT LIKE, and IN. In this exercise, you will try to use some of these together. Writing more complex queries will be standard for you as you become a qualified SQL programmer.

As this query will be a little more complicated than what you've seen so far, we've included a bit of code to get you started. You will be using DISTINCT here too because, surprise, there are two movies named 'Hamlet' in this dataset!

Follow the instructions to find out what 90's films we have in our dataset that would be suitable for English-speaking teens.

Spinner
DataFrameas
df
variable
WHERE xxxx LIKE 'A%' ---- TODOS LOS QUE EMPIEZAN POR A
Spinner
DataFrameas
df
variable

-- Count the unique titles
SELECT COUNT (DISTINCT title) AS nineties_english_films_for_teens
FROM films
-- Filter to release_years to between 1990 and 1999
WHERE release_year BETWEEN '1990'and'1999'
-- Filter to English-language films
AND (language = 'English')
-- Narrow it down to G, PG, and PG-13 certifications
AND certification IN('G','PG','PG-13')
Spinner
DataFrameas
df
variable
SELECT ROUND(AVG(facebook_likes), 1 ) AS avg_facebook_likes
FROM reviews

Find how many decades the films table covers by using MIN() and MAX() and alias as number_of_decades.

Spinner
DataFrameas
df
variable
SELECT (MAX(release_year) - MIN(release_year)) / 10.0 AS number_of_decades
FROM films;