SQL Queries in MySQL Counting This is using the Sakila Sampl


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)

Solution

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\' ;

 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 pe
 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 pe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site