When window functions are evaluated
Window functions and GROUP BY
Summary

Instruction

Great job. So, to sum up this section, remember the following rule: the only places where we can use window functions without having to write subqueries are the SELECT and ORDER BY clauses. In all other places you have to use subqueries.

Exercise

You've seen several examples where the window function was placed in the SELECT clause, but how about trying to put it in the ORDER BY clause now?

For each auction, show the following columns: id, views and quartile based on the number of views in descending order. Order the rows by the quartile.

Stuck? Here's a hint!

In the ORDER BY clause, write the same window function as in the SELECT clause.

Console

Code editor

Result

TableConsole