Member-only story
In SQL, an aggregate function is a function where the values of multiple rows are grouped together to form a single value. These functions are often used in conjunction with the GROUP BY clause to perform operations on groups of rows rather than individual rows. Here are some common aggregate functions in SQL:
1. COUNT():
- Counts the number of rows in a result set or the number of non-null values in a specific column.
SELECT COUNT(*) FROM table_name;
2. SUM():
- Calculates the sum of values in a numeric column.
SELECT SUM(column_name) FROM table_name;
3. AVG():
- Calculates the average of values in a numeric column.
SELECT AVG(column_name) FROM table_name;
4. MIN():
- Returns the minimum value in a column.
SELECT MIN(column_name) FROM table_name;
5. MAX():
- Returns the maximum value in a column.
SELECT MAX(column_name) FROM table_name;
6. GROUP_CONCAT():
- Concatenates the values of a column for each group…