SlideShare a Scribd company logo
3
Most read
6
Most read
13
Most read
Database Management
System
Rayhan Chowdhury
22nd Batch , Exam Roll-796
Department of Computer Science and Engineering
22 September ,
2018
Aggregate function
Aggregate function
Aggregate functions are functions that take a collection of values as input and return a single value.
► Behavior of Aggregate Functions:
*Operates - on a single column
*Return - a single value.
*Ignore NULL Values
The ISO standard defines five (5) Aggregate Functions
5 built in aggregate functions in SQL
Count01
02
04
03
05
SUM
AVG
MAX
MIN
AVG
It returns the average of a data value
Syntax :
SELECT AVG [column-name] FROM [Table-name]
E_ID E_Name Age City Salary
E_001 Rakib 24 Dhaka 20,000
E_002 Rafi 21 Savar 18,000
E_003 Razu 30 khulna 35,000
E_004 Rayhan 21 Savar 22,000
E_005 Rahul 19 Sylhet 26,000
Table Name- Employee
Input :
SELECT AVG (Salary) FROM Employee
Example :
Output :
AVG (Salary) = 24,200
SUM
It returns the addition of a data value
Syntax :
SELECT SUM [column-name] FROM [Table-name]
E_ID E_Name Age City Salary
E_001 Rakib 24 Dhaka 20,000
E_002 Rafi 21 Savar 18,000
E_003 Razu 30 khulna 35,000
E_004 Rayhan 21 Savar 22,000
E_005 Rahul 19 Sylhet 26,000
Table Name- Employee
Input :
SELECT SUM (Salary) FROM Employee
Example :
Output :
SUM (Salary) = 121,000
MAX
It returns the maximum value of a column
Syntax :
SELECT MAX [column-name] FROM [Table-name]
E_ID E_Name Age City Salary
E_001 Rakib 24 Dhaka 20,000
E_002 Rafi 21 Savar 18,000
E_003 Razu 30 khulna 35,000
E_004 Rayhan 21 Savar 22,000
E_005 Rahul 19 Sylhet 26,000
Table Name- Employee
Input :
SELECT MAX (Age) FROM Employee
Example :
Output :
MAX (Age) = 30
MIN
It returns the minimum value of a column
Syntax :
SELECT MIN [column-name] FROM [Table-name]
E_ID E_Name Age City Salary
E_001 Rakib 24 Dhaka 20,000
E_002 Rafi 21 Savar 18,000
E_003 Razu 30 khulna 35,000
E_004 Rayhan 21 Savar 22,000
E_005 Rahul 19 Sylhet 26,000
Table Name- Employee
Input :
SELECT MIN (Salary) FROM Employee
Example :
Output :
MIN (Salary) = 18,000
COUNT
It returns total number of values in a given
column
Syntax :
SELECT COUNT [column-name] FROM [Table-name]
E_ID E_Name Age City Salary
E_001 Rakib 24 Dhaka 20,000
E_002 Rafi 21 Savar 18,000
E_003 Razu 30 khulna 35,000
E_004 Rayhan 21 Savar 22,000
E_005 Rahul 19 Sylhet 26,000
Table Name- Employee
Input :
SELECT COUNT (E_ID) FROM Employee
Example :
Output :
COUNT (E_ID) = 5
Any Question!!
Aggregate function

More Related Content

PPT
Aggregate functions
PPT
MYSQL Aggregate Functions
PPTX
sql function(ppt)
PPT
Sql operators & functions 3
PPTX
Data Manipulation Language
PPTX
PPTX
Oracle Database Sequence
PPT
Sequences and indexes
Aggregate functions
MYSQL Aggregate Functions
sql function(ppt)
Sql operators & functions 3
Data Manipulation Language
Oracle Database Sequence
Sequences and indexes

What's hot (20)

PPTX
DATABASE CONSTRAINTS
PPTX
Sql subquery
PPTX
SQL(DDL & DML)
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
PPTX
SQL commands
PPT
Joins in SQL
PPTX
SQL JOIN
PPTX
SQL - DML and DDL Commands
PPTX
Sql Constraints
PDF
Database Normalization
PPTX
Lab2 ddl commands
PPTX
PPTX
Sql queries presentation
PPTX
Types Of Keys in DBMS
PPT
SQL select statement and functions
PPTX
SQL Queries Information
PPTX
Aggregate functions in SQL.pptx
PPT
SQL subquery
DATABASE CONSTRAINTS
Sql subquery
SQL(DDL & DML)
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
SQL commands
Joins in SQL
SQL JOIN
SQL - DML and DDL Commands
Sql Constraints
Database Normalization
Lab2 ddl commands
Sql queries presentation
Types Of Keys in DBMS
SQL select statement and functions
SQL Queries Information
Aggregate functions in SQL.pptx
SQL subquery
Ad

Similar to Aggregate function (20)

PPTX
Aggregate Function - Database
PPTX
V22 function-1
PDF
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
PPT
Aggregate Functions,Final
PPT
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
PPT
PHP mysql Aggregate functions
PPTX
AGGREGATE FUNCTION.pptx
PPTX
aggregatefunction-220420051702.pptx aggregate
PPTX
SQL.pptx
PDF
Introduction to oracle functions
DOCX
Database Query Using SQL_ip.docx
PPTX
Lecture 8 DML3 aggregate functions in DB.pptx
PPTX
Lab3 aggregating data
PPT
e computer notes - Aggregating data using group functions
PPTX
Oracle select statment
PPTX
Oracle selectstatmentbasics
PPT
Chapter5.ppt
PDF
Sql group functions
PPT
Aggregate functions
PDF
MySQL-commands.pdf
Aggregate Function - Database
V22 function-1
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
Aggregate Functions,Final
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
PHP mysql Aggregate functions
AGGREGATE FUNCTION.pptx
aggregatefunction-220420051702.pptx aggregate
SQL.pptx
Introduction to oracle functions
Database Query Using SQL_ip.docx
Lecture 8 DML3 aggregate functions in DB.pptx
Lab3 aggregating data
e computer notes - Aggregating data using group functions
Oracle select statment
Oracle selectstatmentbasics
Chapter5.ppt
Sql group functions
Aggregate functions
MySQL-commands.pdf
Ad

Recently uploaded (20)

PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Business Ethics Teaching Materials for college
PPTX
Cell Structure & Organelles in detailed.
PDF
Classroom Observation Tools for Teachers
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Complications of Minimal Access Surgery at WLH
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Pre independence Education in Inndia.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Institutional Correction lecture only . . .
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Business Ethics Teaching Materials for college
Cell Structure & Organelles in detailed.
Classroom Observation Tools for Teachers
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial disease of the cardiovascular and lymphatic systems
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Complications of Minimal Access Surgery at WLH
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPH.pptx obstetrics and gynecology in nursing
Pre independence Education in Inndia.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
VCE English Exam - Section C Student Revision Booklet
Institutional Correction lecture only . . .
Renaissance Architecture: A Journey from Faith to Humanism
Module 4: Burden of Disease Tutorial Slides S2 2025

Aggregate function

  • 1. Database Management System Rayhan Chowdhury 22nd Batch , Exam Roll-796 Department of Computer Science and Engineering 22 September , 2018
  • 3. Aggregate function Aggregate functions are functions that take a collection of values as input and return a single value. ► Behavior of Aggregate Functions: *Operates - on a single column *Return - a single value. *Ignore NULL Values The ISO standard defines five (5) Aggregate Functions
  • 4. 5 built in aggregate functions in SQL Count01 02 04 03 05 SUM AVG MAX MIN
  • 5. AVG It returns the average of a data value Syntax : SELECT AVG [column-name] FROM [Table-name]
  • 6. E_ID E_Name Age City Salary E_001 Rakib 24 Dhaka 20,000 E_002 Rafi 21 Savar 18,000 E_003 Razu 30 khulna 35,000 E_004 Rayhan 21 Savar 22,000 E_005 Rahul 19 Sylhet 26,000 Table Name- Employee Input : SELECT AVG (Salary) FROM Employee Example : Output : AVG (Salary) = 24,200
  • 7. SUM It returns the addition of a data value Syntax : SELECT SUM [column-name] FROM [Table-name]
  • 8. E_ID E_Name Age City Salary E_001 Rakib 24 Dhaka 20,000 E_002 Rafi 21 Savar 18,000 E_003 Razu 30 khulna 35,000 E_004 Rayhan 21 Savar 22,000 E_005 Rahul 19 Sylhet 26,000 Table Name- Employee Input : SELECT SUM (Salary) FROM Employee Example : Output : SUM (Salary) = 121,000
  • 9. MAX It returns the maximum value of a column Syntax : SELECT MAX [column-name] FROM [Table-name]
  • 10. E_ID E_Name Age City Salary E_001 Rakib 24 Dhaka 20,000 E_002 Rafi 21 Savar 18,000 E_003 Razu 30 khulna 35,000 E_004 Rayhan 21 Savar 22,000 E_005 Rahul 19 Sylhet 26,000 Table Name- Employee Input : SELECT MAX (Age) FROM Employee Example : Output : MAX (Age) = 30
  • 11. MIN It returns the minimum value of a column Syntax : SELECT MIN [column-name] FROM [Table-name]
  • 12. E_ID E_Name Age City Salary E_001 Rakib 24 Dhaka 20,000 E_002 Rafi 21 Savar 18,000 E_003 Razu 30 khulna 35,000 E_004 Rayhan 21 Savar 22,000 E_005 Rahul 19 Sylhet 26,000 Table Name- Employee Input : SELECT MIN (Salary) FROM Employee Example : Output : MIN (Salary) = 18,000
  • 13. COUNT It returns total number of values in a given column Syntax : SELECT COUNT [column-name] FROM [Table-name]
  • 14. E_ID E_Name Age City Salary E_001 Rakib 24 Dhaka 20,000 E_002 Rafi 21 Savar 18,000 E_003 Razu 30 khulna 35,000 E_004 Rayhan 21 Savar 22,000 E_005 Rahul 19 Sylhet 26,000 Table Name- Employee Input : SELECT COUNT (E_ID) FROM Employee Example : Output : COUNT (E_ID) = 5