Can anyone explain why Last_Value does not take the last value (which is last as per order by) for all rows ?
select * from mytableone
(Please click on link)
Query Used:
select t.*,
LAST_VALUE(PAST_DUE_COL) OVER (Order by ID) as New_Due_Col
from
mytableone t
Actual Result (Please click on link)
Expecting that all 4 rows of result column-3 should have same value -
'0-30 days past due'
Can someone explain the reason ?
When
ORDER BYis specified, the default window frame isUNBOUNDED PRECEDING AND CURRENT ROW. Your query is functionally identical to:so
LAST_VALUEwill be the current row value.Specify
UNBOUNDED FOLLOWINGto get the LAST_VALUE over the entire result: