sales_by_film_category
Documentation | Sakila |
Name | sales_by_film_category |
Module | Views |
The sales_by_film_category view provides a list of total sales, broken down by individual film category.
Because a film can be listed in multiple categories, it is not advisable to calculate aggregate sales by totalling the rows of this view.
The sales_by_film_category view incorporates data from the category, payment, rental, inventory, film, film_category, and category tables.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | category | varchar(25) | The name of the category. | |||||
The name of the category. |
||||||||
2 | total_sales | decimal(27, 2) | The total sale. | |||||
The total sale. |
Script
select `c`.`name` AS `category`,sum(`p`.`amount`) AS `total_sales` from (((((`sakila`.`payment` `p` join `sakila`.`rental` `r` on((`p`.`rental_id` = `r`.`rental_id`))) join `sakila`.`inventory` `i` on((`r`.`inventory_id` = `i`.`inventory_id`))) join `sakila`.`film` `f` on((`i`.`film_id` = `f`.`film_id`))) join `sakila`.`film_category` `fc` on((`f`.`film_id` = `fc`.`film_id`))) join `sakila`.`category` `c` on((`fc`.`category_id` = `c`.`category_id`))) group by `c`.`name` order by `total_sales` desc |
Exported: 2018-10-12 17:43, Last imported: 2018-08-06 10:44