LAG are 2 functions which are always relative to the current row. Now, we'll get to know three other functions that are independent of the current row.
The first one is
FIRST_VALUE(x). As you may guess, it returns the first value in the column x in the given order. Take a look:
FIRST_VALUE(budget) OVER(ORDER BY opened)
Here, we still sort rows by the opening date (
ORDER BY opened), but we show the lowest budget instead of the first opening date (
FIRST_VALUE(budget)). In this way, we can show the budget for the website that was opened first.
Note that this would be impossible to achieve with a simple
MIN(budget) would simply show the smallest budget: 500 in this case. That is not the same as the budget of the first website (3000).