Skip to content

Instantly share code, notes, and snippets.

@elsangedy
Created August 16, 2021 16:42
Show Gist options
  • Save elsangedy/f1238d481fab4a6e80705730c9b00cd0 to your computer and use it in GitHub Desktop.
Save elsangedy/f1238d481fab4a6e80705730c9b00cd0 to your computer and use it in GitHub Desktop.
update table1 t1
set "order" = t2.seq
from (
select id, row_number () over (partition by target_id order by created_at) as seq
from table2
) as t2
where t1.id = t2.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment