DEV Community

vidhya murali
vidhya murali

Posted on

Aggregate Functions

MAX
The MAX() function returns the largest value of the selected column.

MIN
The MIN() function returns the smallest value of the selected column

Set Column Name

When you use MIN() or MAX(), the returned column will be named min or max by default. To give the column a new name, use the AS keyword

COUNT

The COUNT() function returns the number of rows that matches a specified criterion.

If the specified criterion is a column name, the COUNT() function returns the number of rows with that name.

SUM

The SUM() function returns the total sum of a numeric column.

AVG
The AVG() function returns the average value of a numeric column.

select count(*) from employees

select sum(salary) from employees
select avg(salary) from employees
select max(salary) from employees
select min(salary) from employees

select count(*) from employees
where department='IT'

select avg(salary) from employees
where department='IT'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)