Sql is having so many predefined function and aggregate functions are also part of it. These functions are used to summarize the output. For example, if we want to sum any column, find out the maximum or minimum etc. then we can use these functions.
I am taking following table for this article
We have following types of aggregate function
Count function is used to count given row. for example, we want to count how many employees are taking salary then we will use count function with salary.
select count(salary) as count from employee
it will return following result
This function will also use to count the given row but here * represents the all row. So if we apply this function it will return following count
select count(*) as count from employee
it will return the following output
Count function require column to count data but count(*) will count all rows
Count function do not count NULL values in column but count(*) will count all rows whether any column having null or not.
Sum aggregate function is used to addition of the particular column. For example, if we need to sum all salary then we will use following query
select sum(salary) from employee
it will show following output
Max function is used to display maximum value of the column
select max(salary) from employee
Min function is used to display minimum value of the column
select min(salary) from employee
For any query you can send mail at email@example.com Thanks