C. U.
SHAH (GOVT) POLYTECHNIC
SURENDRANAGAR
COMPUTER ENGINEERING DEPARTMENT
Topic :AGGREGATE FUNCTIONS
Introduction
Aggregate functions in SQL are unique functions that works of rows in a table and produce a single value as a result.
These operations are used to calculate a set numbers and produce summary statics like sum, count, average, maximum, and minimum.
It is also called GROUP FUNCTION.
It is often used with GROUP BY and clause of the SELECT statement.
Functio Description Syntax Example
n Name
Min() Returns the minimum Select min(column_name) from
value in a set table_name) where(condition)
Max() Return the maximum Select max(column_name) from
value in a set table_name where(condition)
Sum() Returns the sum of the Select sum(column_name) from
all distinct value in a table_name
set.It ignore null values where(condition)
Avg() Returns the average of a Select avg(column_name) from
set table name
where(condition)
Count() Returns the number of Select count(column_name) from
items in a set. It is table name where(condition)
ignore null
Count(*) Returns total number of Count( * ) from table_name
rows including NULL in
a table
Advantages Of Aggregate Function
By using aggregate functions, you can ensure data integrity by performing calculations at the database level.
They are useful for performing statistical analysis on data.
Using aggregate functions makes queries more concise and readable.
Aggregate functions are often used in conjunction with the GROUP BY clause to group data based on certain criteria.
Disdvantages Of Aggregate Function
Many aggregate functions require the use of the GROUP BY clause to perform calculations on subsets of data.
They are designed for specific types of calculations such as sum, average, count, etc.
Queries involving multiple aggregate functions and complex groupings can become difficult to understand.
Aggregate functions may not always behave as expected when dealing with NULL values in the dataset.
Applications Of Aggregate Function
In financial databases, aggregate functions are used to calculate totals, averages, or other financial metrics.
They are fundamental to business intelligence applications where users analyze and interpret large datasets.
They are used to clean and preprocess data.
They are used to monitor the performance of systems or processes.