Hey All, I can't find a good explanation of this either, and I feel like no one is really understanding the OPs question. "Why does the field in the ORDER BY clause get applied to the partition when we don't include RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
I am also trying to understand why this is happening.
If we remove the ORDER BY it almost works as expected, because the PARTITION creates the range for the window function, but then if the result set is in a different order, the "last" value will be different because the order is different.
In other window functions the ORDER BY clause does not affect the range of the window. If we compare FIRST_VALUE as an example, we can see that it works as expected without adding "RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
Does anyone know why LAST_VALUE includes the ORDER BY in the partition, or what is actually happening if it is not including ORDER BY in the partition?
Thanks,
Dominic