I got a table myTable.
select ID, Timestamp, Value from myTable order by Timestamp
returns
| ID | Timestamp | Value |
|---|---|---|
| 42 | 2002-03-03T00:34:42 | A |
| 53 | 2002-03-03T00:35:46 | B |
| 21 | 2002-03-03T00:37:02 | A |
| 33 | 2002-03-03T03:12:56 | C |
| 71 | 2002-03-03T10:31:14 | B |
| 16 | 2002-03-03T17:19:21 | A |
I need to divide the rows into series starting with value A. Can anyone write an SQL for a column Series_ID returning the ID of the first rows in each series.
| ID | Series_ID |
|---|---|
| 42 | 42 |
| 53 | 42 |
| 21 | 21 |
| 33 | 21 |
| 71 | 21 |
| 16 | 16 |