SlideShare a Scribd company logo
Welcome to my Presentation
Name: Shahadat Hossain
Id: 133-15-3031
Topic: Aggregate Functions
shahadat3031@gmail.com
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.
Used only in the SELECT list and in the HAVING clause.
Types of SQL Aggregate Functions:
Aggregate
Functions:
Max()
Min()
Avg()
Sum()
Input to Aggregate Function
• SUM and AVG :
 Operates only on collections of numbers .
• MIN , MAX and COUNT
 Operates on collection of numeric and non-numeric
data types.
Each function eliminates NULL values and operates on
Non- null values.
USE OF SUM()
Returns: The sum of the values in a specified
column.
Example: Find the total/sum of the Managers
salary
Query:
SELECT SUM( salary) AS sum_salary
FROM Staff
WHERE Staff.position = ‘Manager’;
Result:
sum_salary
54000.00
USE OF AVG()
Returns: The average of the values in a specified column.
Example: Find the average of the Project Managers salary .
Query:
SELECT AVG(ALL salary) AS avg_salary
FROM Staff
WHERE Staff.position = ‘Project Manager’;
Result :
avg_salary
11000.00
Staff
sno fname lname salary position
SL100 John White 30000.00 Manager
SL101 Susan Brand 24000.00 Manager
SL102 David Ford 12000.00 Project
Manager
SL103 Ann Beech 12000.00 Project
Manager
SL104 Mary Howe 9000.00 Project
Manager
MIN() and MAX()
Returns: MIN() returns the smallest value of a column.
MAX() returns the largest value of a column.
Example: Find the minimum and maximum staff salary.
Query:
SELECT MIN( salary) AS min_salary, MAX (salary) AS
max_salary
FROM Staff;
Result: min_salary max_salary
9000.00 30000.00
USE OF COUNT()
Returns: The number of values in the specified column.
Example: Count number of staffs who are Manager.
Query: SELECT COUNT(sno) AS sno_count
FROM Staff
WHERE Staff.position = ‘Manager’;
Result:
sno_count
2
Use of COUNT() and SUM()
Example: Find the total number of Managers and the sum of there
salary.
Query: SELECT COUNT( sno) AS sno_count , SUM(salary) AS
sum_salary
From Staff
WHERE Staff.position = ‘Manager’;
sno fname lname salary position
SL100 John White 30000.00 Manager
SL101 Susan Brand 24000.00 Manager
SUMCOUNT
COUNT() and SUM() continued
• Result:
sno_count sum_salary
2 54000.00
Aggregate Function - Database
Aggregate Function - Database

More Related Content

What's hot

SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
Ritwik Das
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
Mohan Kumar.R
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
rehaniltifat
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
Single row functions
Single row functionsSingle row functions
Single row functions
Balqees Al.Mubarak
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
Anusha sivakumar
 
Cursors
CursorsCursors
SQL Queries
SQL QueriesSQL Queries
SQL Queries
Nilt1234
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
NITISH KUMAR
 
MYSQL Aggregate Functions
MYSQL Aggregate FunctionsMYSQL Aggregate Functions
MYSQL Aggregate Functions
Leroy Blair
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Ddl & dml commands
Ddl & dml commandsDdl & dml commands
Ddl & dml commands
AnjaliJain167
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
Mudasir Syed
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 

What's hot (20)

SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
Sql commands
Sql commandsSql commands
Sql commands
 
Single row functions
Single row functionsSingle row functions
Single row functions
 
set operators.pptx
set operators.pptxset operators.pptx
set operators.pptx
 
Cursors
CursorsCursors
Cursors
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
MYSQL Aggregate Functions
MYSQL Aggregate FunctionsMYSQL Aggregate Functions
MYSQL Aggregate Functions
 
8. sql
8. sql8. sql
8. sql
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Ddl & dml commands
Ddl & dml commandsDdl & dml commands
Ddl & dml commands
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Trigger
TriggerTrigger
Trigger
 
PHP mysql Aggregate functions
PHP mysql Aggregate functionsPHP mysql Aggregate functions
PHP mysql Aggregate functions
 
SQL Server Stored procedures
SQL Server Stored proceduresSQL Server Stored procedures
SQL Server Stored procedures
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 

Viewers also liked

Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
mukesh24pandey
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group Functions
Salman Memon
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
rainynovember12
 
Agreggates i
Agreggates iAgreggates i
Agreggates i
Claudia Gomez
 
Dbms4
Dbms4Dbms4
Cellular Telephone Networks 2008
Cellular Telephone Networks 2008Cellular Telephone Networks 2008
Cellular Telephone Networks 2008
Francisco Villegas
 
namecard
namecardnamecard
namecard? ?
 
7 relational database design algorithms and further dependencies
7 relational database design algorithms and further dependencies7 relational database design algorithms and further dependencies
7 relational database design algorithms and further dependenciesKumar
 
Cellular Telephone Systems
Cellular Telephone SystemsCellular Telephone Systems
Cellular Telephone Systems
Shantanu Krishna
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebraguest20b0b3
 
New Perspectives: Access.03
New Perspectives: Access.03New Perspectives: Access.03
New Perspectives: Access.03
Anna Stirling
 
Relational Algebra-Database Systems
Relational Algebra-Database SystemsRelational Algebra-Database Systems
Relational Algebra-Database Systemsjakodongo
 
SQL Joins
SQL JoinsSQL Joins
SQL Joins
Paul Harkins
 
Sql joins
Sql joinsSql joins
Sql joins
Gaurav Dhanwant
 
functional dependencies with example
functional dependencies with examplefunctional dependencies with example
functional dependencies with example
Siddhi Viradiya
 
Basic structures in vhdl
Basic structures in vhdlBasic structures in vhdl
Basic structures in vhdlRaj Mohan
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbmsshekhar1991
 

Viewers also liked (20)

Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group Functions
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Agreggates i
Agreggates iAgreggates i
Agreggates i
 
Dbms4
Dbms4Dbms4
Dbms4
 
Cellular Telephone Networks 2008
Cellular Telephone Networks 2008Cellular Telephone Networks 2008
Cellular Telephone Networks 2008
 
namecard
namecardnamecard
namecard
 
7 relational database design algorithms and further dependencies
7 relational database design algorithms and further dependencies7 relational database design algorithms and further dependencies
7 relational database design algorithms and further dependencies
 
Cellular Telephone Systems
Cellular Telephone SystemsCellular Telephone Systems
Cellular Telephone Systems
 
Ch 17
Ch 17Ch 17
Ch 17
 
Unit05 dbms
Unit05 dbmsUnit05 dbms
Unit05 dbms
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
New Perspectives: Access.03
New Perspectives: Access.03New Perspectives: Access.03
New Perspectives: Access.03
 
Relational Algebra-Database Systems
Relational Algebra-Database SystemsRelational Algebra-Database Systems
Relational Algebra-Database Systems
 
Normalization
NormalizationNormalization
Normalization
 
SQL Joins
SQL JoinsSQL Joins
SQL Joins
 
Sql joins
Sql joinsSql joins
Sql joins
 
functional dependencies with example
functional dependencies with examplefunctional dependencies with example
functional dependencies with example
 
Basic structures in vhdl
Basic structures in vhdlBasic structures in vhdl
Basic structures in vhdl
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 

Similar to Aggregate Function - Database

SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhhSQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
NaveeN547338
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
SabrinaShanta2
 
Dynamic websites lec2
Dynamic websites lec2Dynamic websites lec2
Dynamic websites lec2Belal Arfa
 
Sub queries
Sub queriesSub queries
Sub queries
VARSHAKUMARI49
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
Abrar ali
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptxAGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
Anusha sivakumar
 
Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docx
VandanaGoyal21
 
Sql functions
Sql functionsSql functions
Sql functions
ilias ahmed
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
MrHello6
 
Nikhil Khandelwal BCA 3rd Year
Nikhil Khandelwal BCA 3rd YearNikhil Khandelwal BCA 3rd Year
Nikhil Khandelwal BCA 3rd Year
dezyneecole
 
Les06
Les06Les06
Sql intro
Sql introSql intro
Sql introglubox
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
Achmad Solichin
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
Soumyajit Dutta
 

Similar to Aggregate Function - Database (20)

SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhhSQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
SQL-AGG-FUN.pdfiiiijuyyttfffgyyuyyyyyhhh
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
 
Dynamic websites lec2
Dynamic websites lec2Dynamic websites lec2
Dynamic websites lec2
 
V22 function-1
V22 function-1V22 function-1
V22 function-1
 
Module03
Module03Module03
Module03
 
Sub queries
Sub queriesSub queries
Sub queries
 
Sql FUNCTIONS
Sql FUNCTIONSSql FUNCTIONS
Sql FUNCTIONS
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptxAGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
 
Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docx
 
Sql functions
Sql functionsSql functions
Sql functions
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Clauses
ClausesClauses
Clauses
 
SQL BASIC QUERIES
SQL  BASIC QUERIES SQL  BASIC QUERIES
SQL BASIC QUERIES
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
 
Nikhil Khandelwal BCA 3rd Year
Nikhil Khandelwal BCA 3rd YearNikhil Khandelwal BCA 3rd Year
Nikhil Khandelwal BCA 3rd Year
 
Les06
Les06Les06
Les06
 
Les17
Les17Les17
Les17
 
Sql intro
Sql introSql intro
Sql intro
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 

Recently uploaded

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 

Recently uploaded (20)

Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 

Aggregate Function - Database

  • 1. Welcome to my Presentation Name: Shahadat Hossain Id: 133-15-3031 Topic: Aggregate Functions shahadat3031@gmail.com
  • 2. 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. Used only in the SELECT list and in the HAVING clause.
  • 3. Types of SQL Aggregate Functions: Aggregate Functions: Max() Min() Avg() Sum()
  • 4. Input to Aggregate Function • SUM and AVG :  Operates only on collections of numbers . • MIN , MAX and COUNT  Operates on collection of numeric and non-numeric data types. Each function eliminates NULL values and operates on Non- null values.
  • 5. USE OF SUM() Returns: The sum of the values in a specified column. Example: Find the total/sum of the Managers salary Query: SELECT SUM( salary) AS sum_salary FROM Staff WHERE Staff.position = ‘Manager’; Result: sum_salary 54000.00
  • 6. USE OF AVG() Returns: The average of the values in a specified column. Example: Find the average of the Project Managers salary . Query: SELECT AVG(ALL salary) AS avg_salary FROM Staff WHERE Staff.position = ‘Project Manager’; Result : avg_salary 11000.00
  • 7. Staff sno fname lname salary position SL100 John White 30000.00 Manager SL101 Susan Brand 24000.00 Manager SL102 David Ford 12000.00 Project Manager SL103 Ann Beech 12000.00 Project Manager SL104 Mary Howe 9000.00 Project Manager
  • 8. MIN() and MAX() Returns: MIN() returns the smallest value of a column. MAX() returns the largest value of a column. Example: Find the minimum and maximum staff salary. Query: SELECT MIN( salary) AS min_salary, MAX (salary) AS max_salary FROM Staff; Result: min_salary max_salary 9000.00 30000.00
  • 9. USE OF COUNT() Returns: The number of values in the specified column. Example: Count number of staffs who are Manager. Query: SELECT COUNT(sno) AS sno_count FROM Staff WHERE Staff.position = ‘Manager’; Result: sno_count 2
  • 10. Use of COUNT() and SUM() Example: Find the total number of Managers and the sum of there salary. Query: SELECT COUNT( sno) AS sno_count , SUM(salary) AS sum_salary From Staff WHERE Staff.position = ‘Manager’; sno fname lname salary position SL100 John White 30000.00 Manager SL101 Susan Brand 24000.00 Manager SUMCOUNT
  • 11. COUNT() and SUM() continued • Result: sno_count sum_salary 2 54000.00