Search your topic here

SQL Functions

SQL FUNCTIONS


Five Important aggregate functions are SUM, AVG, MIN, MAX and COUNT. They are called aggregate functions because they summarize the results of a query, rather than listing all of the rows.
  1. SUM () gives the total of all the rows, satisfying any conditions, of the given column, where the given column is numeric.
  2. AVG () gives the average of the given column.
  3. MIN () gives the smallest figure in the given column.
  4. MAX () gives the largest figure in the given column.
  5. COUNT () gives the number of rows satisfying the conditions
1. SUM( ):

The SUM function returns the total sum of a column. NULL values are not included in the calculation.

Syntax :
SELECT SUM (column) FROM table

For example:
SELECT SUM (RollNumber) FROM Student;

2. AVG( ):

The AVG function returns the average value of a column in a selection. NULL values are not included in the calculation.

Syntax :
SELECT AVG (column) FROM table

For example:
SELECT AVG(RollNumber) FROM Student;

3. MIN( ):

The MIN function returns the lowest value in a column. NULL values are not included in the calculation.

Syntax :
SELECT MIN(column) FROM table;

For example:
SELECT MIN(RollNumber) FROM Student;

4. MAX( ):

The MAX function returns the highest value in a column. NULL values are not included in the calculation.

Syntax :
SELECT MAX(column) FROM table;

For example:
SELECT MAX(RollNumber) FROM Student;

5. COUNT( ):

The keyword COUNT can be used together to count the number of distinct results. 

Syntax :
SELECT COUNT (column) FROM table;

For example:
SELECT COUNT (RollNumber) FROM Student;

LEAVE A REPLY