Instruction
Before we start writing queries with PARTITION BY and ORDER BY, let's quickly review how we use PARTITION BY in queries. Take a look:
SELECT Country, City, Rating, AVG(Rating) OVER(PARTITION BY Country) AS AvgRating 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 StoreId, the Day, the Revenue on that day and the average Revenue in that store. Name the last column AvgRevenue.
Stuck? Here's a hint!
Use PARTITION BY StoreId.



