How can I get incrementing number for this table?

This is an events table I have. How can I write a query to add column X which increments when it encounters 1 in the event column

INPUT:

|id    |event|
|------|-----|
|1     |0    |
|2     |0    |
|3     |1    |
|4     |0    |
|5     |1    |
|6     |0    |
|7     |0    |
|8     |0    |
|9     |1    |
|10    |0    |

EXPECTED OUTPUT:

|id    |event| X |
|------|-----|---|
|1     |0    | 1 |
|2     |0    | 1 |
|3     |1    | 2 |
|4     |0    | 2 |
|5     |1    | 3 |
|6     |0    | 3 |
|7     |0    | 3 |
|8     |0    | 3 |
|9     |1    | 4 |
|10    |0    | 4 |

Answer

You just want a cumulative sum of event:

select t.*,
       (sum(event) over (order by id) + 1) as x
from t;