Solution to Activity 5.1
In this activity, you will execute a few queries to get data that can be used by a manager for marketing and to reduce costs. Follow these steps to complete this activity:
- Open the MySQL client and connect to the
sakila
database:USE sakila;
- Find the total number of films the store has with a
PG
rating. To do this, you need both thefilm
table and theinventory
table. For every item in theinventory
table, there is a reference to a record in thefilm
table. Then, filter on the rating, which is stored in thefilm
table. And finally, doSELECT COUNT(*)
because all you need is the total number aggregated over all rows:SELECT COUNT(*) FROM film f JOIN inventory i ON f.film_id=i.film_id WHERE f.rating='PG';
The preceding query produces the following output:
- Now, find films in which
Emily Dee
has performed as an...