CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

MySQL Aggregate Functions

 

MySQL Aggregate Functions

An aggregate function performs a calculation on multiple values and returns a single value.


1. MAX ()

MAX function returns the maximum value of an expression.

Syntax:
SELECT MAX(aggregate_expression)
FROM tables
[WHERE conditions];

Parameter or Arguments:
aggregate_expression: This is the column or expression from which the maximum value will be returned.

2. MIN ()

MIN function returns the minimum value of an expression.

Syntax:
SELECT MIN(aggregate_expression)
FROM tables
[WHERE conditions];

Parameter or Arguments:
aggregate_expression: This is the column or expression from which the minimum value will be returned.

3. AVG ()

AVG function returns the average value of an expression.

Syntax:
SELECT AVG(aggregate_expression)
FROM tables
[WHERE conditions];

Parameter or Arguments:
aggregate_expression: This is the column or expression that will be averaged.


4. SUM ()

SUM function returns the summed value of an expression.

Syntax:
SELECT SUM(aggregate_expression)
FROM tables
[WHERE conditions];

Parameter or Arguments:
aggregate_expression: This is the column or expression that will be summed.

5. COUNT () and COUNT (*)

COUNT function returns the count of an expression.

Syntax:
SELECT COUNT(aggregate_expression)
FROM tables
[WHERE conditions];

Parameter or Arguments:
aggregate_expression: This is the column or expression whose non-null values will be counted.




No comments:

Post a Comment