Good job. Before, we said that window functions were calculated after the
GROUP BY clause. This has a very important implication for our queries: if the query uses any aggregates,
GROUP BY or
HAVING, the window function sees the group rows instead of the original table rows.
To get a better understanding of this phenomenon, take a look at the following example:
This simple query will show the
final_price of each auction alongside the average
final_price from all the auctions. Now, take a look at the modified example with grouping:
GROUP BY category_id;
Will this query work? Let's find out!