Instruction
Before we start writing queries with PARTITION BY ORDER BY, let's quickly revise queries with PARTITION BY alone. Take a look:
SELECT country, city, rating, AVG(rating) OVER(PARTITION BY country) FROM store;
In the above query, we show the rating of each store plus the average rating calculated for the respective country. If we hadn't used PARTITION BY country, we would have ended up with an average across all stores. This way, we get separate average values for each country.
Exercise
For each sales row, show the store_id, day, revenue on that day and the average revenue in that store.
Stuck? Here's a hint!
Use PARTITION BY store_id.



