Computer Science, asked by beautymani0328, 1 month ago


Explain to the following functions
with example -
(i) Sum
(ii) Average
(iii) Max
(iv) Min
(V) count​

Answers

Answered by Anonymous
6

Answer:

1.COUNT Function

The COUNT function returns the total number of values in the specified field. It works on both numeric and non-numeric data types. All aggregate functions by default exclude nulls values before working on the data.

COUNT (*) is a special implementation of the COUNT function that returns the count of all the rows in a specified table. COUNT (*) also considers Nulls and duplicates.

2.MAX function

Just as the name suggests, the MAX function is the opposite of the MIN function. It returns the largest value from the specified table field.

Let's assume we want to get the year that the latest movie in our database was released. We can easily use the MAX function to achieve that.

3.SUM function

Suppose we want a report that gives total amount of payments made so far. We can use the MySQL SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.

4.AVG function

MySQL AVG function returns the average of the values in a specified column. Just like the SUM function, it works only on numeric data types.

Answered by swayamshri08
0

Answer:

Explanation:

AVG() – returns the average value.

COUNT() – returns the number of values.

MAX() – returns the maximum value.

MIN() – returns the minimum value.

SUM() – returns the sum of all or distinct values.

AVG(): The AVG() function allows you to calculate the average value of a numeric column.

syntax : AVG(column)

SELECT AVG(SALARY) "AVERAGE SAL" FROM empl;

Output :

AVERAGE SAL

22000.0000

COUNT(): The COUNT function returns the total number of values in the specified field.

syntax : COUNT(expression)

SELECT COUNT(*) FROM empl;

Output :

count(*)

       6

MAX() : It returns the maximum value from the specified table field.

syntax : MAX(expression)

SELECT MAX(Salary) FROM empl;

Output :

MAX(Salary)

    30000

MIN(): The MIN function returns the minimum value in the specified table field.

syntax : MIN(expression)

SELECT MIN(Salary)FROM empl;

Output :

MIN(Salary)

      12000

SUM(): SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.

syntax : SUM(expression)

SELECT SUM(Salary) "Total Salary" from empl;

Output :

Total Salary

132000

These functions are called aggregate functions because they operate on the aggregate of tuples. The result of an aggregate function is a single value

Similar questions