I\'m using Oracle PL/SQL.
I have a timestamped table T, and I want to set a row\'s value for column A to be the same as that of the previous row, if they\'re sorted
And another option... doesn't quite do what do want because it ignores the requirement to sort on B but it might give you something to think about.... Without table definitions and things it was a little hard to get a handle on exactly what was required.
Edit: on reading the question again, it looks like your syntax is wrong. Group functions (lead/lag/rank etc) can only appear in the select list or the order by clause. They are evaluated after the joins, where, group by and having clauses. So something like what is shown below should work.
update T a
set A = (select
new_A
from (
select
B,
A,
timestamp,
first_value(A)
over (order by timestamp range between 45 preceding and current row) as new_A
from mike_temp_1
) b where b.id = a.id)