Functions SQL Aggregate Functions | COUNT(), AVG(), SUM() In SQL Server

Functions SQL Aggregate Functions | COUNT(), AVG(), SUM() In SQL Server

An aggregate function allows you to perform the calculation on a set of values to return the single scalar value. Aggregate Functions are used for performing operations on multiple rows of a particular column and result in a single value. SQL aggregate functions are inbuilt functions that are used for performing various operations in data.

Count() in SQL

The count() function is used to count a total number of records in a table with a condition or without a condition.

Syntax

Select count(column_name) from table_name;

Example:

Select count(Email) from customers
Select count(Amount) from customers where amount > 5000

Sum() in SQL

The sum() function is used to return the submission of all numeric values in a column.

Syntax:

 

Select SUM(column_name) from table_name

Example:

 

Select sum(amount) from customer

Avg() in SQL

The AVG() function is used to return an average value after the calculation performed in a numeric column

Syntax:

 

Select avg (column_name) from table_name

Example:

 

select avg(amount) from customer

 

 

 

 

2020-04-09