1 of 21

Challenge! �

2 of 21

Overview

  • General Challenge Tasks utilizing all the skills you’ve learned so far!
  • Hints to the challenge
  • Solution to the challenge

  • Challenges are going to be difficult, so try breaking down the problem into individual tasks!

3 of 21

Challenge

  • How many payment transactions were greater than $5.00?

4 of 21

Hints

You will need to use the payment table

You will also need to use COUNT and WHERE along with some comparison operator

5 of 21

SOLUTION

SELECT COUNT(amount) FROM payment

WHERE amount > 5;

6 of 21

Challenge

  • How many actors have a first name that starts with the letter P?

7 of 21

Hints

You will need to use the actor table

You will also need to use LIKE and a wildcard operator, such as % or _

8 of 21

SOLUTION

SELECT COUNT(*) FROM actor

WHERE first_name LIKE 'P%';

9 of 21

Challenge

  • How many unique districts are our customers from?

10 of 21

Hints

You will need to use the address table

You will also need to use COUNT and DISTINCT

11 of 21

SOLUTION

SELECT COUNT(DISTINCT(district))

FROM address;

12 of 21

Challenge

  • Retrieve the list of names for those distinct districts from the previous question.

13 of 21

Hints

You will again need to use the address table

This will be very similar to the previous challenge

14 of 21

SOLUTION

SELECT DISTINCT(district) FROM address;

15 of 21

Challenge

  • How many films have a rating of R and a replacement cost between $5 and $15?

16 of 21

Hints

You will need to use the film table.

You may also need to use BETWEEN and a WHERE statement with a comparison operator.

17 of 21

SOLUTION

SELECT COUNT(*) FROM film

WHERE rating = 'R'

AND replacement_cost BETWEEN 5 AND 15;

18 of 21

Challenge

  • How many films have the word Truman somewhere in the title?

19 of 21

Hints

You will need to use the film table

You will also need to use LIKE with a wildcard operator

20 of 21

SOLUTION

SELECT COUNT(*) FROM film

WHERE title LIKE '%Truman%';

21 of 21

Great job!

  • Let’s go learn some more!