Kodewick
Start learning →
Mini challenge←→0 / 70

Orders per movie

#064Mini challengeSubqueriesAggregates6 min

The cinema wants each movie's number of tickets rows, and movies with none should show 0. Pick each movie's title and how many rows it has in tickets, counted with a small query.

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 title,
  -- your code here: in brackets, a COUNT(*) query that only counts rows whose movie_id is this movie's id
FROM movies;
Ctrl + Enter runs too
Result

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