Introduction
PARTITION BY
9. OVER(PARTITION BY) – practice 1
Revision

Instruction

Fantastic. Let's do a couple of exercises to practise.

Exercise

For each journey, show its id, the production_year of the train on that journey, the number of journeys the train took and the number of journeys on the same route.

Stuck? Here's a hint!

Use COUNT(journey.id) twice, but with different OVER(PARTITION BY) clause. Join two tables.

Console

Code editor

Result

TableConsole