I have this record set returned , now I want to have a row number column which gets reset after every 3rd row. Can anyone help me with this? needs to be done with Oracle SQL. Explanation below-
| data | current row number | rquired row number |
|---|---|---|
| Chris | 1 | 1 |
| Bryan | 2 | 2 |
| Jim | 3 | 3 |
| Davis | 4 | 1 |
| Kia | 5 | 2 |
| Jones | 6 | 3 |
| Mary | 7 | 1 |
| Carrie | 8 | 2 |
| Pearce | 9 | 3 |
| Cesar | 10 | 1 |
| Bob | 11 | 2 |
You can mod the current value:
So using a CTE to represent your current result set:
db<>fiddle