AGGREGATE FUNCTION
PREPARED BY
MS.G.ABIRAMI – III - B.SC - INFORMATION TECHNOLOGY
UNDER THE GUIDANCE OF
MRS.P.ANUSHA M.SC(IT).,M.PHIL.,D.P.T.T.,(PH.D).,
ASSISTANT PROFESSOR,
DEPARTMENT OF INFORMATION TECHNOLOGY,
BON SECOURS COLLEGE FOR WOMEN,
THANJAVUR.
SQL AGGREGATE FUNCTION
 SQL aggregation function is used to perform the calculation
on multiple rows of a single column of a table. It returns a
single value.
 It is also used to summarize the data.
 This function ignore the null values except the count
function .
TYPES OF SQL AGGREGATION FUNCTION
Count ( ) : Returns the numbers of rows
Sum ( ) : Returns the sum
Avg ( ) : Returns the average value
Max ( ) : Returns the smallest value
Min ( ) : Returns the largest value
COUNT FUNCTION
Count function is used to count the number of rows in database table
.It can work on both numeric and non-numeric data types.
Count function uses the count (*) that returns the count of all the
rows in a specific table. Count (*) considers duplicate and null .
This function does not count the null value .
Table name :Employee
EXAMPLE :TABLE
NAME DATE PAGES
RAMU 22022-01-12 34
GEETHA 22022-01-12 74
SEETHA 22022-01-12 64
RAM 22022-01-12 94
SUKRIA 22022-01-12 64
SYNTAX OF COUNT
Syntax: select count(Pages) from employee;
Count (pages)
5
1 row in set
Syntax: select count (name) from employee;
Count(name)
5
1 row in set
SUM FUNCTION
• Sum() function is an aggregate function that calculates the sum of
all or distinct values in an expression .
SYNTAX: SELECT SUM (PAGES) FROM EMPLOYEE;
SUM(PAGES)
330
1 ROW IN A SET
AVERAGE FUNCTION
• The avg function is used to calculate the average value of the
numeric type. Average function returns the average of all non-null
values.
syntax: select avg (pages)from employee;
avg(pages)
66.0000
1row in set
MAX FUNCTION
• Max function is used to find the maximum value of certain column.
This function determines the largest value of all selected values of
columns.
Syntax: select max (pages) from employee;
Max(pages)
94
1 row in set
MIN FUNCTION
• The Min function is used to find the minimum value of certain
column. This function determines the smallest value of all selected
values of a column.
syntax: Select min(pages)from employee ;
Min(pages)
34
1 row in set

AGGREGATE FUNCTION.pptx

  • 1.
  • 2.
    PREPARED BY MS.G.ABIRAMI –III - B.SC - INFORMATION TECHNOLOGY UNDER THE GUIDANCE OF MRS.P.ANUSHA M.SC(IT).,M.PHIL.,D.P.T.T.,(PH.D)., ASSISTANT PROFESSOR, DEPARTMENT OF INFORMATION TECHNOLOGY, BON SECOURS COLLEGE FOR WOMEN, THANJAVUR.
  • 3.
    SQL AGGREGATE FUNCTION SQL aggregation function is used to perform the calculation on multiple rows of a single column of a table. It returns a single value.  It is also used to summarize the data.  This function ignore the null values except the count function .
  • 5.
    TYPES OF SQLAGGREGATION FUNCTION Count ( ) : Returns the numbers of rows Sum ( ) : Returns the sum Avg ( ) : Returns the average value Max ( ) : Returns the smallest value Min ( ) : Returns the largest value
  • 6.
    COUNT FUNCTION Count functionis used to count the number of rows in database table .It can work on both numeric and non-numeric data types. Count function uses the count (*) that returns the count of all the rows in a specific table. Count (*) considers duplicate and null . This function does not count the null value . Table name :Employee
  • 7.
    EXAMPLE :TABLE NAME DATEPAGES RAMU 22022-01-12 34 GEETHA 22022-01-12 74 SEETHA 22022-01-12 64 RAM 22022-01-12 94 SUKRIA 22022-01-12 64
  • 8.
    SYNTAX OF COUNT Syntax:select count(Pages) from employee; Count (pages) 5 1 row in set Syntax: select count (name) from employee; Count(name) 5 1 row in set
  • 9.
    SUM FUNCTION • Sum()function is an aggregate function that calculates the sum of all or distinct values in an expression . SYNTAX: SELECT SUM (PAGES) FROM EMPLOYEE; SUM(PAGES) 330 1 ROW IN A SET
  • 10.
    AVERAGE FUNCTION • Theavg function is used to calculate the average value of the numeric type. Average function returns the average of all non-null values. syntax: select avg (pages)from employee; avg(pages) 66.0000 1row in set
  • 11.
    MAX FUNCTION • Maxfunction is used to find the maximum value of certain column. This function determines the largest value of all selected values of columns. Syntax: select max (pages) from employee; Max(pages) 94 1 row in set
  • 12.
    MIN FUNCTION • TheMin function is used to find the minimum value of certain column. This function determines the smallest value of all selected values of a column. syntax: Select min(pages)from employee ; Min(pages) 34 1 row in set