The aggregate function aggregates the values of the columns specified in the argument and returns the result; if the WHERE condition is specified, it returns the aggregate result for the extracted records.
SQL provides the following functions. SUM and AVG cannot take non-numeric arguments.
|SUM||Sum of arguments: if NULL, not included in the tally|
|MAX||Find the maximum value of the argument.|
|MIN||Find the minimum value of the argument.|
|AVG||Find the average value of the arguments; if NULL, it is not included in the tally.|
|COUNT||If it is NULL, it is not counted.Can be described as COUNT(*).|
Now for the Practice, I will give you two questions.
Find the sum, maximum, minimum, mean, and total number of SALs (salaries) from the EMP Table.
The average can also be obtained arithmetically as SUM(SAL)/COUNT(SAL).
Find the maximum and minimum value of the SAL (salary) from the EMP Table for the JOB (job) 'SALESMAN'.
|WHERE||JOB = 'SALESMAN'|
Only records matching the WHERE condition will be processed by the set function.
This completes Functions (SUM, MAX, MIN, AVG, COUNT).