, . : A00-B99, C00-D48, D50-D89,
code_group Count
A00-A99 10
B00-C48 50
C49-D99 100
therefore, you used the wrong desired result group A00-A99 , C49-D99 , because they do not correspond to the ranges that you previously announced.
Here is an example of how to group a table with A00-A99; B00-B99 ...
:
http://sqlfiddle.com/#!9/63229/3
SELECT
CONCAT(LEFT(codes,1),'00-',LEFT(codes,1),'99') gr ,
COUNT(*)
FROM myTable
GROUP BY LEFT(codes,1);
But if you really need these weird ranges as a group, I suggest you set up another table, for example:
http://sqlfiddle.com/#!9/3eca4/3
CREATE TABLE myGroups (
id INT AUTO_INCREMENT PRIMARY KEY,
minGr varchar(10),
maxGr varchar(10)
);
and your request could be:
SELECT
CONCAT(g.minGr,'-',g.maxGr) gr ,
COUNT(*)
FROM myTable t
INNER JOIN myGroups g
ON t.codes>=g.minGr
AND t.codes<=g.maxGr
GROUP BY g.id
ORDER BY g.id;