I have the below sql table
DECLARE @TESTTABLE TABLE(ID INT, CODE NVARCHAR(5), VALUE INT)
INSERT INTO @TESTTABLE
VALUES (1,'C1',3), (2,'C1',4), (3,'C1',2), (4,'C2',4), (5,'C2',5), (6,'C2',7), (7,'C3',1), (8,'C4',3), (9,'C4',8)
SELECT * FROM @TESTTABLE
And I need the output would be - Sum over partition by with id and the value should be reset with code (this is not static and should be anything).
I have tried this below query but how to reset the value using code.
SELECT ID, CODE, VALUE, SUM(VALUE) OVER (ORDER BY ID) AS RESULT FROM @TESTTABLE

