Update rows in table with id from row before in PostgreSQL
You can get your desired result by using LAG() function.

select
    id,
    grp,
    time_added,
    lag(id) over (partition by grp order by grp, time_added) previous_id
from
    tbl;


You can update in this way:

with x as
(
    select
        id,
        lag(id) over (partition by grp order by grp, time_added) previous_id
    from
        tbl
)
update tbl
set    
    previous_id = x.previous_id
from
    x
where
    x.id = tbl.id;


db&lt;>fiddle here