Kodewick
Start learning →
Mini challenge←→0 / 70

Seats sold

#068Mini challengeJOINNULL7 min

The cinema wants a list of how many seats each movie sold (seats added up). The starter's LEFT JOIN already keeps the movies with no tickets, but their total comes out empty; make it 0. Pick title and the seat count.

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,
  -- your code here: wrap SUM(tickets.seats) in COALESCE(…, 0)
  SUM(tickets.seats)
FROM movies
LEFT JOIN tickets ON tickets.movie_id = movies.id
GROUP BY movies.title;
Ctrl + Enter runs too
Result

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