SELECT COUNT(idcompra)
FROM compra
WHERE YEAR(fecha_compra) = 2021 GROUP BY MONTH(fecha_compra)
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