public.sales_by_film_category
Documentation | Pagila |
Schema | public |
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 | character varying(25) | The name of the category. | |||||
The name of the category. |
||||||||
2 | total_sales | numeric | The total sale. | |||||
The total sale. |
Uses
Name |
---|
public.sales_by_film_category
|
Script
SELECT c.name AS category, sum(p.amount) AS total_sales FROM (((((payment p JOIN rental r ON ((p.rental_id = r.rental_id))) JOIN inventory i ON ((r.inventory_id = i.inventory_id))) JOIN film f ON ((i.film_id = f.film_id))) JOIN film_category fc ON ((f.film_id = fc.film_id))) JOIN category c ON ((fc.category_id = c.category_id))) GROUP BY c.name ORDER BY (sum(p.amount)) DESC; |
Exported: 2018-10-12 17:07, Last imported: 2018-08-06 09:25