Kodewick
Start learning →
Mini challenge←→0 / 70

Box office

#010Mini challengeJOINGROUP BY6 min

The weekend is over and the cinema wants to see the box office. Join movies and tickets, work out how much each movie made (its tickets' price added up), and sort from most to least. Movies with no tickets sold don't need to be listed.

The tables
movies
idtitlegenreminutesrating
1Robot Summerfamily958
2Dark Lakehorror1106
3Space Palsfamily887
4The Long Roaddrama1429
5Laugh Trackcomedy1015
6Snow Daycomedy927
6 rows
tickets
idmovie_iddayseatsprice
11Fri240
21Sat480
32Fri125
43Sat354
54Sun260
61Sun120
75Sat236
83Sun590
8 rows
query.sql
SELECT movies.title, SUM(tickets.price)
FROM movies
JOIN tickets ON tickets.movie_id = movies.id
-- your code here: GROUP BY the title, then ORDER BY SUM(tickets.price) from high to low
;
Ctrl + Enter runs too
Result

Run shows what your query gives. When it looks right, Submit.