Aggregate functions in SQL

 Aggregate functions:
Ø Aggregate functions are used to perform calculations on a data set to get the single value from the user defined data.
Uses of Aggregate functions:
Ø It performs arithmetic operation as well as calculation on set values and returns a single value.
Ø Aggregate functions used with the group by clause of the select statement.
Ø Aggregate functions ignores all null values (Except Count(*).
What are Aggregate functions?
1.    Max()
2.    Min()
3.    Avg()
4.    Count()
5.    Sum()
Max():
 Max() function used to find the largest value in the selected column.
Syntax:

  1. Select Max (column_name)
    From table_name;

Example:

  1. Select Max (sal)
    From emp;

Min():
 Max() function used to find the largest value in the selected column.
Syntax:

  1. Select Min (column_name)
    From table_name;

Example:

  1. Select Min (sal)
    From emp;

Avg():
Avg() function is used to return the average value of the numeric column.
Syntax:

  1. Select Avg (column_name)
    From table_name;

Example:

  1. Select Avg (Price)
    From Book;

Sum():
Sum() function is used to return average value of the numeric column.
Syntax:

  1. Select  Sum (column_name)
    From table_name;

Example:

  1. Select Sum (sal+comm)
    From emp;
Example:2

  1. Select Sum (sal)
    From emp
  2. where deptno=10;

Count():
Count() function is used to return the number of rows or records in the table.
Syntax:

  1. Select Count (column_name)
    From table_name;

Example:1

  1. Select Count (*)
    From emp;

Example:2

  1. Select Count (Emp_name)
    From emp;






Share:

No comments:

Post a Comment

Popular Posts

Search This Blog

Powered by Blogger.

Blog Archive

Service Support

Need our help to Learn or Post New Concepts Contact me

Blog Archive

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me