MySQL Aggregate Functions - Explain MySQL Aggregate Functions.

Explain MySQL Aggregate Functions.

Aggregate functions in MySQL are a group of functions that are used to operate on a set of values. These functions ignore NULL values unless specified. Functions like AVG(), MIN(), MAX(), COUNT() etc fall under this category. As they operate on a set of values, if no Group by clause is used, it applies to all rows.

Explain the following functions with an example.

1. AVG()
Returns the average of the parameter passed. Returns 0 if no matching rows found.

Example:
Avg(salary)
2. COUNT()
Counts the number of NON NULL values of the parameter passed. Returns 0 if no matching rows found.

Example:
Select employee_id, COUNT(*) from table_name;
3. MAX()
Returns the maximum value of the parameter passed. Returns 0 if no matching rows found.

Example:
Select MAX(employee_salary) from table_name
4. MIN()
Returns the minimun value of the parameter passed. Returns 0 if no matching rows found.

Example:
Select MIN(employee_salary) from table_name
5. SUM()
Returns the sum of the parameter passed. Returns NULL if no matching rows found.

Example:
Select SUM(employee_salary) from table_name

Explain MySQL Aggregate Functions.

1. AVG () : Returns the average value of the given argument.
2. BIT_AND () : Returns the result of bitwise AND
3. BIT OR () : Returns the result of bitwise OR
4. BIT XOR () : Returns the result of bitwise XOR
5. COUNT () : Returns number of rows
6. COUNT (DISTINCT) : Returns the count of unique values.
7. GROUP_CONCAT () : Returns concatenated string
8. MAX () : Returns the maximum value
9. MIN () : Returns the minimum value
10. STD () : Returns the standard deviation
11. SUM () : Returns the sum of a set of values
12. VAR () : Returns the variance
MySQL - Describe Transaction-Safe Table Types in MySQL
MySQL Transaction-Safe Table - While using transactions in MySQL a transaction –safe table type must be used. MyISAM is the default table type....
MySQL Connection - Describe MySQL Connection using mysql binary
MySQL Connection - Establishing connection to MySQL database using Mysql binary can be done at command prompt....
MySQL - Explain advantages of MyISAM over InnoDB?
Explain advantages of MyISAM over InnoDB? - MyISAM is faster than InnoDB in most of the cases. MyISAM table is stored....
Post your comment