Trying to find an efficient way to create the column C values which is based on column B and increments based on B being 1 or -1 and the count restarts when B switches between B being 1 or -1.
CREATE TABLE #T (a int, b int, c int);
INSERT INTO #T VALUES (1, 1, 1),
(2, 1, 2),
(3, -1, -1),
(4, -1, -2),
(5, -1, -3),
(6, -1, -4),
(7, 1, 1),
(8, 1, 2);
Thank you!