Sales of Genres in Cities
Opgave
Swipe to start coding
Which genre gives the biggest income in each city? To solve it:
- Calculate the total sales for each genre in each city: group records by city and genre.
- Order the records by city lexicographically and then by total sales, starting with most selling genre.
Output data under columns city
, genre
, and sales
.
Løsning
9
1
2
3
4
5
6
7
select city, g.label as genre, sum(sales) as sales
from genre as g
left join movie as m on m.genre_id = g.id
inner join schedule as s on s.movie_id = m.id
inner join cinema as c on s.cinema_id = c.id
group by city, g.id
order by city, sales desc
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 6
9
1
No query executed yet... |
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat