SlideShare ist ein Scribd-Unternehmen logo
1 von 16
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

Weitere ähnliche Inhalte

Was ist angesagt?

MYSQL Aggregate Functions
MYSQL Aggregate FunctionsMYSQL Aggregate Functions
MYSQL Aggregate FunctionsLeroy Blair
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL CommandsShrija Madhu
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries LectureFelipe Costa
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answersMichael Belete
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptxAnkit Rai
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3Mohd Tousif
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLMSB Academy
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functionsAmrit Kaur
 
sql function(ppt)
sql function(ppt)sql function(ppt)
sql function(ppt)Ankit Dubey
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Deepam Aggarwal
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
SQL Queries
SQL QueriesSQL Queries
SQL QueriesNilt1234
 

Was ist angesagt? (20)

MYSQL Aggregate Functions
MYSQL Aggregate FunctionsMYSQL Aggregate Functions
MYSQL Aggregate Functions
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answers
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
SQL practice questions - set 3
SQL practice questions - set 3SQL practice questions - set 3
SQL practice questions - set 3
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQL
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
PL/SQL TRIGGERS
PL/SQL TRIGGERSPL/SQL TRIGGERS
PL/SQL TRIGGERS
 
sql function(ppt)
sql function(ppt)sql function(ppt)
sql function(ppt)
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 

Ähnlich wie Aggregate function (20)

Aggregate Function - Database
Aggregate Function - DatabaseAggregate Function - Database
Aggregate Function - Database
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
 
Sql intro
Sql introSql intro
Sql intro
 
Module03
Module03Module03
Module03
 
MySQL-commands.pdf
MySQL-commands.pdfMySQL-commands.pdf
MySQL-commands.pdf
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhhSQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
 
PPT
PPTPPT
PPT
 
Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
V34 numeric function-c
V34  numeric function-cV34  numeric function-c
V34 numeric function-c
 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
 
Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docx
 
sql language
sql languagesql language
sql language
 
Les01 Writing Basic Sql Statements
Les01 Writing Basic Sql StatementsLes01 Writing Basic Sql Statements
Les01 Writing Basic Sql Statements
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
ORACLE NOTES
ORACLE NOTESORACLE NOTES
ORACLE NOTES
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptxUnit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
 

Kürzlich hochgeladen

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 

Kürzlich hochgeladen (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 

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