Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views2 pages

Aggregate Functions in SQL

Aggregate functions in SQL group multiple row values to produce a single meaningful value. Key functions include Count(), Sum(), Avg(), Min(), and Max(), each with specific calculations based on the data. Examples demonstrate how these functions operate on a salary dataset, providing insights like total records, sums, averages, and extreme values.

Uploaded by

Geetanjali Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Aggregate Functions in SQL

Aggregate functions in SQL group multiple row values to produce a single meaningful value. Key functions include Count(), Sum(), Avg(), Min(), and Max(), each with specific calculations based on the data. Examples demonstrate how these functions operate on a salary dataset, providing insights like total records, sums, averages, and extreme values.

Uploaded by

Geetanjali Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Aggregate functions in SQL

In database management an aggregate function is a function where the values of multiple rows
are grouped together as input on certain criteria to form a single value of more significant
meaning.
Various Aggregate Functions
1) Count()
2) Sum()
3) Avg()
4) Min()
5) Max()
Now let us understand each Aggregate function with a example:
Id Name Salary
-----------------------
1 A 80
2 B 40
3 C 60
4 D 70
5 E 60
6 F Null
1. Count():

Count(*): Returns total number of records .i.e 6.


Count(salary): Return number of Non Null values over the column salary. i.e 5.
Count(Distinct Salary): Return number of distinct Non Null values over the column salary .i.e 4

2. Sum():

sum(salary): Sum all Non Null values of Column salary i.e., 310
sum(Distinct salary): Sum of all distinct Non-Null values i.e., 250.

3. Avg():

Avg(salary) = Sum(salary) / count(salary) = 310/5


Avg(Distinct salary) = sum(Distinct salary) / Count(Distinct Salary) = 250/4
4. Min():

Min(salary): Minimum value in the salary column except NULL i.e., 40.

5.Max():

Max(salary): Maximum value in the salary i.e., 80.

You might also like