Does the filter condition (updates.last_record = 1) needs to be applied as a outer query after applying last_value function , looking at the query plan from Snowflake, current code is applying the filter first to get the latest record and then its executing the last value function on the latest record.
Query plan with filter applied in the inner query :

Query plan after filter applied in the outer query :

Does the filter condition (updates.last_record = 1) needs to be applied as a outer query after applying last_value function , looking at the query plan from Snowflake, current code is applying the filter first to get the latest record and then its executing the last value function on the latest record.
Query plan with filter applied in the inner query :
Query plan after filter applied in the outer query :
