Instruction
The query worked fine this time. Here's one thing you should remember: while FIRST_VALUE works well with the default window frame, LAST_VALUE needs an explicit definition of the right window frame to actually make sense.
Of course, you can order by one column and return the other:
SELECT
name,
budget,
LAST_VALUE(budget) OVER(
ORDER BY opened
ROWS BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING)
FROM website;
Here we show the budget of the most recent website (not the greatest budget).
Now, you're ready to write your own example!
Exercise
Show the statistics for website_id = 1. For each row, show the day, the number of impressions and the number of impressions on the day with the most users.
Stuck? Here's a hint!
Use LAST_VALUE(impressions) and sort by the number of users.



