I'm trying to do something that is simple in excel but I need it to be added in my query. I am trying to create a cumulative sum in a new column of time values in one column if a name column equals a previous row. Example of before and after below
Data Input Table
| ID | Time |
|---|---|
| A | 2 |
| B | 3 |
| C | 1 |
| D | 0.5 |
| E | 1 |
| E | 3 |
| E | 5 |
| F | 2 |
| G | 3 |
| G | 4 |
| H | 1 |
Table After Query
| ID | Time | BeforeStart |
|---|---|---|
| A | 2 | 0 |
| B | 3 | 0 |
| C | 1 | 0 |
| D | 0.5 | 0 |
| E | 1 | 0 |
| E | 3 | 1 |
| E | 5 | 4 |
| F | 2 | 0 |
| G | 3 | 0 |
| G | 4 | 3 |
| H | 1 | 0 |
Basically if column ID equals the row above itself then sum the time and BeforeStart rows above itself, if it doesn't then it is 0.
