I've a table Serial with more than a million records. Few of the sample varchar(MAX) of values are given below:
SerialNumber
1
2
3
4
7
8
9
13
14
15
19
21
I wish to group continuous range of values with same group into a sets like this:
fromSerial toSerial Total
1 4 4
7 9 3
13 15 3
19 19 1
21 21 1
Please help me to achieve this.