Aggregate Function in SQL

Rumman Ansari   Software Engineer   2023-03-25   5719 Share
☰ Table of Contents

Table of Content:


An aggregate function in SQL is a function that takes a group of rows and produces a single value. This value can be the sum, the average, the minimum, or the maximum of the values in the group.

  1. SUM(): calculates the total sum of a numeric column.
  2. AVG(): calculates the average of a numeric column.
  3. MIN(): returns the minimum value in a column.
  4. MAX(): returns the maximum value in a column.
  5. COUNT(): returns the number of rows in a table, or the number of rows that match a specific condition.

Aggregate functions can be used with the GROUP BY clause in SQL to group the results by a specific column or set of columns, and apply the aggregate function to each group separately. This allows you to perform calculations and summarize data based on different criteria.