When window functions are evaluated
Window functions and GROUP BY
Summary

Instruction

Okay. The best way to correctly create queries with window functions and GROUP BY is as follows: first, create the query with GROUP BY, but without window functions. Run the query (in the database or in your head). Now, the columns you see in the result are the only columns you can use in your window functions.

Exercise

Group the auctions by the country. Show the country, the minimal number of participants in an auction and the average minimal number of participants across all countries.

Stuck? Here's a hint!

Use

AVG(MIN(participants)) OVER()
as your window function.

Console

Code editor

Result

TableConsole