strawquery PT
All lessons

Lesson 30 of 30

The board meeting

Today at the studio

It is the big day. The board is in the meeting room, Nagi is wearing a tie for the first time, and Byte has been sitting in the best chair since eight. Rin slides a list of questions toward you: "You know everything you need." You open the editor and type.

The idea

There is nothing new in this lesson. Every question uses ideas you have already met: joins, groups, subqueries, and sometimes several at once.

Take them one step at a time. First decide which tables you need, then the rows you keep, then the groups, then the order. When something goes wrong, read the error message: it usually points close to the problem.

Example

SELECT shows.title
FROM shows
WHERE shows.budget_millions > (SELECT AVG(budget_millions) FROM shows)
  AND EXISTS (SELECT 1 FROM episodes WHERE episodes.show_id = shows.id)

Your turn

0 of 5 questions

Question 1 of 5

The board asks which three shows earned the most from merch. Show title and revenue (price times units_sold, added up), biggest first.

The order of the rows counts in this question.

Unofficial fan project. Titles belong to their creators and rights holders.