By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
| id | location_id | quantity | transferred_quantity_total | remaining_qty |
|---|---|---|---|---|
| id1 | 1 | 10 | 2 | 8 |
| id2 | 2 | 10 | 3 | 7 |
SELECT 2