0% found this document useful (0 votes)
12 views1 page

Aggregates

Aggregate functions in SQL perform calculations on sets of values and return a single result. Common aggregate functions include COUNT, SUM, AVG, MIN, MAX, and GROUP_CONCAT, which count rows, calculate sums, averages, minimums, maximums, and concatenate values. Aggregate functions are often used with the GROUP BY clause to summarize data across groups.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Aggregates

Aggregate functions in SQL perform calculations on sets of values and return a single result. Common aggregate functions include COUNT, SUM, AVG, MIN, MAX, and GROUP_CONCAT, which count rows, calculate sums, averages, minimums, maximums, and concatenate values. Aggregate functions are often used with the GROUP BY clause to summarize data across groups.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Aggregates in SQL are functions that perform a calculation on a set of values

and return a single value as the result. These functions are often used in
conjunction with the `GROUP BY` clause to summarize data. Some common aggregate
functions in SQL include:

1. **COUNT**: Counts the number of rows in a result set. It can be used to count
all
rows or, when combined with `GROUP BY`, the number of rows within each
group.

2. **SUM**: Calculates the sum of values in a numeric column.

3. **AVG**: Calculates the average (mean) of values in a numeric column.

4. **MIN**: Finds the minimum (smallest) value in a column.

5. **MAX**: Finds the maximum (largest) value in a column.

6. **FIRST**: Returns the first value in a set. It is not supported by all database

systems.

7. **LAST**: Returns the last value in a set. It is not supported by all database
systems.

8. **VARIANCE**: Calculates the variance of values in a numeric column, indicating


how much the values differ from the mean.

9. **STDDEV**: Calculates the standard deviation, which measures the amount of


variation or dispersion in a set of values.

10. **GROUP_CONCAT** (or equivalent functions): Concatenates values from multiple


rows into a single string. This is often used to create
comma-separated lists or other forms of delimited strings.

11. **STRING_AGG** (SQL Server) or **LISTAGG** (Oracle): Similar to `GROUP_CONCAT`,

these functions concatenate values from multiple rows into a single


string.

These are some of the commonly used aggregate functions in SQL. The specific
aggregate functions available may vary depending on the database system you are
using, and some database systems might provide additional custom aggregate
functions.
The choice of aggregate function depends on the type of analysis you want to
perform
on your data.

You might also like