home / sakila

sales_by_film_category (view)

16 rows

✎ View and edit SQL

This data as json, xlsx, CSV (advanced)

category total_sales
Action 4375.85
Animation 4656.3
Children 3655.55
Classics 3639.59
Comedy 4383.58
Documentary 4217.52
Drama 4587.39
Family 4226.070000000001
Foreign 4270.67
Games 4281.33
Horror 3722.54
Music 3417.7200000000003
New 4351.62
Sci-Fi 4756.9800000000005
Sports 5314.21
Travel 3549.6400000000003

Advanced export

JSON shape: default, array, newline-delimited

CSV options:

CREATE VIEW sales_by_film_category
AS
SELECT
c.name AS category
, SUM(p.amount) AS total_sales
FROM payment AS p
INNER JOIN rental AS r ON p.rental_id = r.rental_id
INNER JOIN inventory AS i ON r.inventory_id = i.inventory_id
INNER JOIN film AS f ON i.film_id = f.film_id
INNER JOIN film_category AS fc ON f.film_id = fc.film_id
INNER JOIN category AS c ON fc.category_id = c.category_id
GROUP BY c.name;
Powered by Datasette · Queries took 371.439ms