CREATE TABLE tablename (
  `Id` INTEGER,
  `offset` INTEGER,
  `length` INTEGER
);

INSERT INTO tablename
  (`Id`, `offset`, `length`)
VALUES
  ('5000', '0', '5'),
  ('5001', '5', '5'),
  ('5002', '10', '4'),
  ('5003', '14', '4'),
  ('5010', '23', '5'),
  ('5011', '28', '5');

UPDATE tablename AS t1
SET offset = t2.offset
FROM (
  SELECT Id, SUM(length) OVER (ORDER BY Id ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) offset
  FROM tablename 
) AS t2
WHERE t2.Id = t1.Id AND t2.offset IS NOT NULL;

SELECT * FROM tablename;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: