Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Window functions and GROUP BY
Summary and Review

Instruction

As you can see, the query failed. However, let's take a look at another modification of this example:

SELECT
  CategoryId,
  MAX(FinalPrice) AS MaxFinal,
  AVG(MAX(FinalPrice)) OVER() AS AvgMaxFinalPrice
FROM Auction
GROUP BY CategoryId;

What will happen now?

Exercise

Run the template.

This query succeeded because we used an aggregate function (MAX(FinalPrice)) that was indeed available after grouping the rows. By the way, this is the only place where you can nest aggregate functions inside one another.