I have a table like below. Each city will have a row where `TYPE` = `Active` and `Month` = `0` then there will be an `X` number of `Push` rows, starting with `Month` = `0` going to `Month` = `X`. In the example below `X` = `3`.

I need to create a query that generates the second table.

Basically, for each city:

* take the `Active` and `Push` value for `Month` = `0` and add them to get the `Final` value for `Month` = `0`
* then for each `Month`, take the previous month's `Final` value and add it to the months `Push` value from the first table.

I think I have to use `SUM` and `OVER` or `ROLLUP` but I am not sure how or where to start.

SQL Fiddle does not seem to be working so I have included the CREATE/INSERT statements to initialize the first table.

Edit: I found `db<>fiddle` - <https://dbfiddle.uk/?rdbms=sqlserver_2014&fiddle=9dab5f207b97a318c7d0f26369a4b3ed>.

First Table
===========

```
+-------+--------+-------+-------+
| CITY  |  TYPE  | MONTH | VALUE |
+-------+--------+-------+-------+
| one   | Active | 0     | 222   |
| one   | Push   | 0     | -7    |
| one   | Push   | 1     | 1     |
| one   | Push   | 2     | -6    |
| one   | Push   | 3     | 0     |
| two   | Active | 0     | 363   |
| two   | Push   | 0     | -5    |
| two   | Push   | 1     | 4     |
| two   | Push   | 2     | -5    |
| two   | Push   | 3     | 5     |
| three | Active | 0     | 394   |
| three | Push   | 0     | 10    |
| three | Push   | 1     | 5     |
| three | Push   | 2     | -8    |
| three | Push   | 3     | 0     |
+-------+--------+-------+-------+

```

Expected Output
===============

```
+-------+-------+-------+-------+
| CITY  | TYPE  | MONTH | VALUE |
+-------+-------+-------+-------+
| one   | Final | 0     | 215   | 222 + -7 (add the active and next rows for month 0 for city one from the first table)
| one   | Final | 1     | 216   | 215 + 1 (previous month's final from this table plus this months push from the other table)
| one   | Final | 2     | 210   | 216 + -6 (previous month's final from this table plus this months push from the other table)
| one   | Final | 3     | 210   | ...etc
| two   | Final | 0     | 358   | 363 + -5 (add the active and next rows for month 0 for city two from the first table)
| two   | Final | 1     | 362   | ...etc
| two   | Final | 2     | 357   | ...etc
| two   | Final | 3     | 362   | ...etc
| three | Final | 0     | 404   | ...etc
| three | Final | 1     | 409   | ...etc
| three | Final | 2     | 401   | ...etc
| three | Final | 3     | 401   | ...etc
+-------+-------+-------+-------+

```

Init SQL
========

```
CREATE TABLE cities
(
    [city] varchar(10)
  , [type] varchar(10)
  , [month] int
  , [value] int
);

INSERT INTO cities ([city], [type], [month], [value])
VALUES
    ('one','Active',0,222),
    ('one','Push',0,-7),
    ('one','Push',1,1),
    ('one','Push',2,-6),
    ('one','Push',3,0),
    ('two','Active',0,363),
    ('two','Push',0,-5),
    ('two','Push',1,4),
    ('two','Push',2,-5),
    ('two','Push',3,5),
    ('three','Active',0,394),
    ('three','Push',0,10),
    ('three','Push',1,5),
    ('three','Push',2,-8),
    ('three','Push',3,0)
;

```