Code has been added to clipboard!

Get to Know SQL Aggregate Functions and How They Work

Reading time 1 min
Published Aug 9, 2017
Updated Oct 11, 2019

TL;DR – SQL aggregate functions allow you to perform calculations on multiple values and get a single value as a result.

SQL Aggregate Functions Explained

Counting in SQL is very similar to Microsoft Excel. Whenever you need to work with multiple values in the same table row, you can use arithmetical operators (+, -, * or /). However, if the values are in multiple rows, you will need to use SQL aggregate functions.

Using aggregate functions in SQL, you can apply calculations to whole table columns and work with thousands of rows at once. This is especially helpful when you need to quickly summarize data and see the big picture instead of analyzing individual entries.

Aggregate Functions in SQL: A List

Function Result
AVG() The average of a set of values
COUNT() The number of rows in a column
MAX() The biggest value in a column
MIN() The smallest value in a column
SUM() The sum of values in a column

SQL Aggregate Functions: Useful Tips

  • Before you start working with data, all aggregate functions in SQL have a value of Null.
  • You can combine SQL aggregate functions with the ROUND() function to round up numeric values.
Learn SQL
Introduction
Syntax
Data Types
Server Data Types
Commands
Commands List
Wildcards
Constraints
Aggregate Functions
Date Functions
Date Format
Injection
SQL Server Hosting
Views
Auto-incrementation
SQL Operators
AS
AND & OR
IN
BETWEEN
WHERE
GROUP BY
HAVING
ORDER BY
LIKE
NOT
NOT EQUAL
UNION
NULL
NOT NULL
DEFAULT
UNIQUE
FOREIGN KEY
PRIMARY KEY
CHECK
Indexes
ALTER TABLE
CREATE DATABASE
CREATE TABLE
DELETE
DROP
INSERT INTO SELECT
INSERT INTO
SELECT
SELECT DISTINCT
SELECT INTO
SELECT TOP
UPDATE
FULL OUTER JOIN
INNER JOIN
JOIN
LEFT JOIN
RIGHT JOIN
AVG()
COUNT
FIRST
LAST
MAX
MIN()
SUM()
LEN
UCASE
MID
NOW
ROUND
FORMAT
LOWER
CONVERT
ISNULL