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

ntotalavg
5530000106000.0