Aggregation in SQL: COUNT, SUM, AVG and GROUP BY

Aggregation functions and grouping with GROUP BY and HAVING, with a real query runner.

Las funciones de agregación resumen muchas filas en un solo valor: cuántas hay (COUNT), la suma (SUM), la media (AVG)… Con GROUP BY calculas ese resumen por grupos.

SELECT ciudad, COUNT(*), AVG(edad)
FROM usuarios
GROUP BY ciudad;

Query runner

WHERE vs HAVING

The sample tables

Check what you've learned