add remove split language chart show hidden hide
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 12
usr month_series eligibility running_amt new_amt desired_result
1 1 1 0 0 0
1 2 0 150 150 0
1 3 0 150 0 0
1 4 1 1000 850 1000
1 5 0 1200 200 0
1 6 0 1200 0 0
1 7 1 1200 0 200
1 8 0 1500 300 0
1 9 0 1550 50 0
1 10 0 1600 50 0
1 11 1 1600 0 400
1 12 1 1600 0 0
SELECT 12
ALTER TABLE
usr month_series eligibility new_amt desired_result
1 1 1 0 0
1 2 0 150 0
1 3 0 0 0
1 4 1 850 1000
1 5 0 200 0
1 6 0 0 0
1 7 1 0 200
1 8 0 300 0
1 9 0 50 0
1 10 0 50 0
1 11 1 0 400
1 12 1 0 0
SELECT 12