add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE mytable
([Year] int, [Month] int, [Active_Users] int)
;
INSERT INTO mytable
([Year], [Month], [Active_Users])
VALUES
(2022, 1, 123),
(2022, 2, 143),
(2022, 12, 100),
(2023, 1, 79),
(2023, 2, 3)
;

5 rows affected
SELECT YEAR,Month
, CASE WHEN Month = 12 THEN Active_users + (SELECT SUM(Active_users) FROM mytable WHERE YEAR = 2023 AND Month IN (1,2))
ELSE Active_users END Active_users
FROM mytable
WHERe YEAR = 2022

YEAR Month Active_users
2022 1 123
2022 2 143
2022 12 182