transform Count consecutive integers

Viewed 65

i have a dataset like

id
1
2
3
4
7
8

i want my output as:

id   count
1     4
2     4
3     4
4     4
7     2
8     2

Thanks in advance

1 Answers
Related