SQL - Aggregate Functions
Overview
Aggregate functions summarize multiple rows: COUNT, SUM, AVG, MIN, MAX. Combine with GROUP BY and HAVING.
SELECT COUNT(*) AS n, SUM(salary) AS total, AVG(salary) AS avg
FROM employees;
SELECT COUNT(*) AS n, SUM(salary) AS total, AVG(salary) AS avg
FROM employees;
SELECT COUNT(*) AS n, SUM(salary) AS total, AVG(salary) AS avg
FROM employees;
Prerequisite
Load the Standard Test Data.
Expected Output
n | total | avg |
---|---|---|
5 | 530000 | 106000.0 |