Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
When window functions are evaluated
Window functions and GROUP BY


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

  MAX(final_price) AS max_final, 
  AVG(MAX(final_price)) OVER()
FROM auction
GROUP BY category_id;

What will happen now?


Run the template.

As you can see, the query now succeeded because we used an aggregate function (MAX(final_price)) 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.