2

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.

ekad
  • 14,436
  • 26
  • 44
  • 46
  • Your problem is performance. The 'conventional' solution is likely to be agonisingly slow on a data set of this size. I think a solution using a couple of variables is the way to go. – Strawberry Jan 22 '14 at 18:10

0 Answers0