---
title: "Aggregate functions in Database"  
description: "Aggregate functions are applied to agroup of data values from a column. Aggregate functions always return a singlevalue.How database supports followin"  
author: "Amit Singh"  
published: 2010-11-16  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/52/aggregate-functions-in-database  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# Aggregate functions in Database

[Aggregate functions](https://www.mindstick.com/forum/158949/what-are-the-conditional-aggregate-functions-in-sql-such-as-sum-case-and-how-are-they-used) are applied to agroup of data values from a column. Aggregate functions always return a singlevalue.

How [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) [supports](https://www.mindstick.com/blog/12043/how-to-create-a-killer-mobile-app-that-supports-your-brand) following aggregate functions:

**AVG**: Calculates the arithmetic mean (average) of the data valuescontained within a column. The column must contain numeric values.

##### Syntax:

SELECTAVG(column_name) FROM table_name

MAX and MIN: Calculate the maximum and minimum data value of the column,respectively. The column can contain numeric, [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp), and date/time values.

##### Syntax:

\

```
SELECT MAX(column_name) FROM table_nameSELECT MIN(column_name) FROM table_name
SUM: Calculates the total of all data values in a column. The columnmust contain numeric values.
```

\

##### Syntax:

SELECT SUM(column_name) FROM table_name

**COUNT**: Calculates the number of (non-null) data values in a column. Theonly aggregate [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) not being applied to columns is COUNT(*). This functionreturns the number of rows (whether or not particular columns have NULLvalues).

##### Syntax:

SELECT COUNT(column_name) FROM table_name

COUNT_BIG: New and Analogous to COUNT, the only [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) being thatCOUNT_BIG returns a value of the BIGINT data type.

##### Syntax:

COUNT_BIG ( { [ ALL | [DISTINCT](https://www.mindstick.com/forum/159558/why-c-sharp-linq-distinct-doesn-t-work) ] [expression](https://www.mindstick.com/articles/1861/sqlite-expressions) } | * )

##### Aggregatefunction Example:

\

```
   SELECT COUNT(*)FROM tblcheck
```

##### \
Output:

##### CountData

##### 9

· SELECT SUM(empid) AS SumData FROM tblcheck

##### \
Output:

##### \SumData

##### \
45

---

Original Source: https://www.mindstick.com/blog/52/aggregate-functions-in-database

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
