select
case
when RESULT between 0 and 50 then '0-50'
when RESULT between 50 and 100 then '51-100'
when RESULT between 100 and 150 then '101-150'
when RESULT between 150 and 200 then '151-200'
when RESULT between 200 and 250 then '201-250'
else 'OTHERS'
end as `Range`,
count(1) as `Count`
from PERSON
group by `Range`;
SELECT
c1, c2,..., cn, aggregate_function(ci)
FROM
table
WHERE
where_conditions
GROUP BY c1 , c2,...,cn;
SELECT Manufacturer, COUNT(*) AS ModelsCount
FROM Products
WHERE Price > 30000
GROUP BY Manufacturer
ORDER BY ModelsCount DESC