Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Sales of Genres in Cities | Ordering Data
Practice SQL with Cinema Database

book
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

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?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 6

Query ResultQuery Result
No query executed yet...

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt