I have a table with the following structure:
CREATE TABLE `Rings` ( ID_RingType CHAR(2), Number MEDIUMINT UNSIGNED, ID_User INT(11) );
and with data:
INSERT INTO `Rings` VALUES ('AA',1,1), ('AA',2,1), ('AA',3,1), ('AA',11,1), ('AA',12,1), ('AA',13,1), ('AA',14,1), ('AA',15,1), ('AB',16,1), ('AB',17,1), ('AB',18,1), ('AB',19,1), ('AB',20,2), ('AB',21,2), ('AB',22,2);
I wish to group the data based on
ID_RingType and for each contiguous range of numbers list the MIN and MAX.
The results should look like:
ID_User | ID_RingType | MIN | MAX 1 | 'AA' | 1 | 3 1 | 'AA' | 11 | 15 1 | 'AB' | 16 | 19 2 | 'AB' | 20 | 22
I went through several posts on this topic but was not able to tweak them to fit my data.
Any help would be appreciated.