-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSQL_8a.sql
More file actions
21 lines (20 loc) · 811 Bytes
/
Copy pathSQL_8a.sql
File metadata and controls
21 lines (20 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE VIEW top_5_by_genre as
(SELECT
c.name as 'Genre',
SUM(p.amount) as 'Gross Revenue'
FROM
sakila.film f,
sakila.category c,
sakila.film_category fc,
sakila.inventory i,
sakila.payment p,
sakila.rental r
WHERE
c.category_id = fc.category_id
AND f.film_id = fc.film_id
AND i.film_id = f.film_id
AND i.inventory_id = r.inventory_id
AND r.rental_id = p.rental_id
GROUP BY name
ORDER BY SUM(p.amount) DESC
LIMIT 5);