SQL Queries in MySQL: Counting This is using the Sakila Sample database which ca
ID: 3934564 • Letter: S
Question
SQL Queries in MySQL: Counting
This is using the Sakila Sample database which can download here: https://dev.mysql.com/doc/sakila/en
**Note that you will be performing a query on multiple tables. See below the instructions for table names.**
Instructions:
Write a query that produces a count of the number of Action films by looking at the inventory, so that if there are 2 copies of a film it needs to be counted twice.
Schema: sakila
List of Tables
Table Name: film
Column Names: film_id, title, description, release_year, language_id, original_language_id, rental_duration, rental_rate, length, replacement_cost, rating, special_features
Table Name: inventory
Column Names: inventory_id, film_id, store_id, last_update)
SQL Queries in MySQL: Counting
This is using the Sakila Sample database which can download here: https://dev.mysql.com/doc/sakila/en
**Note that you will be performing a query on multiple tables. See below the instructions for table names.**
Instructions:
Write a query that produces a count of the number of Action films by looking at the inventory, so that if there are 2 copies of a film it needs to be counted twice.
Schema: sakila
List of Tables
Table Name: film
Column Names: film_id, title, description, release_year, language_id, original_language_id, rental_duration, rental_rate, length, replacement_cost, rating, special_features
Table Name: inventory
Column Names: inventory_id, film_id, store_id, last_update)
SQL Queries in MySQL: Counting
This is using the Sakila Sample database which can download here: https://dev.mysql.com/doc/sakila/en
**Note that you will be performing a query on multiple tables. See below the instructions for table names.**
Instructions:
Write a query that produces a count of the number of Action films by looking at the inventory, so that if there are 2 copies of a film it needs to be counted twice.
Schema: sakila
List of Tables
Table Name: film
Column Names: film_id, title, description, release_year, language_id, original_language_id, rental_duration, rental_rate, length, replacement_cost, rating, special_features
Table Name: inventory
Column Names: inventory_id, film_id, store_id, last_update)
Explanation / Answer
select count(*) , f.film_id, f.description, i.inventory_id from inventory i inner join film f on f.film_id = i.film_id group by
f.film_id, f.description, i.inventory_id having f.description='action film' ;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.