GROUP BY en SQL

GROUP BY en SQL resume filas en grupos antes de aplicar funciones de agregación. Las consultas group by sql y sql group by son centrales en reporting.

Ejemplo

SELECT region, SUM(ventas) AS total_ventas
FROM tiendas
GROUP BY region;

Toda columna del SELECT que no esté agregada debe aparecer en el GROUP BY (en motores estándar).