I would like to create a SQL query that groups the increase price of items in certain percentage range. For example
2 items increased between 0 to 10 %
4 items i
If You want all ranges by 10: Use:
SELECT (d-10)*10 AS `from` , (d-9)*10 AS `to` , c AS `count` FROM
(SELECT DISTINCT(FLOOR((`p`.`new`*10)/(`p`.`old`))) AS d,
count(1) AS c FROM prices as p GROUP BY 1) AS stats
for such structure:
CREATE TABLE `prices` (
`old` int(11) NOT NULL,
`new` int(11) NOT NULL
);
edit: >=from and < to