Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Best Selling Movies | Aggregating Data
Practice SQL with Cinema Database

book
Best Selling Movies

Tarefa

Swipe to start coding

For each cinema, let's order movies from the most selling to the least one. Print records in the following format: cinema_id, movie_id, sales (for total sales). Remember to order records by cinema's first but by total sales then (starting with the best selling one).

Solução

select s.cinema_id as cinema_id, s.movie_id as movie_id, sum(s.sales) as sales
from schedule as s
group by cinema_id, movie_id
order by cinema_id, sales desc

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 4

toggle bottom row
Query ResultQuery Result
No query executed yet...
some-alt