Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
PARTITION BY
6. PARTITION BY – first exercise
Summary

Instruction

As you can see, the query works fine. Imagine writing the same query using regular GROUP BY: you'd have to use a correlated subquery and a JOIN. The query would neither be readable nor efficient.

We no longer want to pay that price and PARTITION BY is the solution. Thanks to PARTITION BY, we can easily get the information about individual rows AND the information about the groups these rows belong to. 

Exercise

Show the id of each journey, its date and the number of journeys that took place on that date.

Stuck? Here's a hint!

Use COUNT(id) OVER(PARTITION BY date).