×

Aggregate Functions in DBMS

Aggregate Functions in DBMS: Aggregate functions are those functions in the DBMS which takes the values of multiple rows of a single column and then form a single value by using a query. These functions allow the user to summarizing the data. These functions ignore the NULL values except the count function.

In Database Management System, following are the five aggregate functions:

1. AVG

2. COUNT

3. SUM

4. MIN

5. MAX

AVG Function

This function takes the values from the given column and then returns the average of the values. This function works only on the datatypes, which are specified as numeric in the table.

Let's take an example, which describes to you how to use the AVG function in SQL. Suppose we want to calculate the average salary from the Employee_Details table, then we have to type the following query:

Select AVG(Employee_salary) from Employee_Details;

COUNT Function

This aggregate function returns the total number of values in the specified column. This function can work on any type of data, i.e., numeric as well as non-numeric. This function does not count the NULL values. If we want to count all the rows with NULL values, then we have to use the Count(*) function.

Let's take an example, which describes to us how to use the COUNT function in SQL. Suppose a user wants to count the number of employees in the Employee_Details table, then we have to type the following query:

Select Count(Employee_ID) from Employee_Details;

SUM Function

This aggregate function sums all the non-NULL values of the given column. Like the AVG function, this function also works only on the numeric data.

Let's take an example, which describes to you how to use the SUM function in SQL. Suppose a user wants to find the sum of salary from the Employee_Details table, then we have to type the following query:

Select SUM(Employee_salary) from Employee_Details;

MAX Function

This function returns the value, which is maximum from the specified column.

Let's take an example, which describes to you how to use the MAX function in SQL. Suppose we want to find the maximum price of the Cars_Price column from the Cars table, then we have to type the following query:

Select MAX(Cars_Price) from Cars;

MIN Function

This function returns the value, which is minimum from the specified column.

Let's take an example, which describes to you how to use the MIN function in SQL. Suppose we want to find the minimum price of the Bikes_Price column from the Bikes table, then we have to type the following query:

Select MIN(Bikes_Price) from Bikes;

Related Topics

Generalization in DBMS

Generalization in DBMS In the database management system, generalization is a concept combining the common attributes of two or more lower-level entity and form a new higher level with the common...

3 minutes read.

Secondary Key in DBMS

What are Keys? Keys in DBMS are the attributes or set of attributes that uniquely identify a row in a set of relations. A table (relation) can have a column or...

3 minutes read.

View Serializability in DBMS

View Serializability It is a type of serializability that can be used to check whether the given schedule is view serializable or not. A schedule called as a view serializable if it is view...

4 minutes read.

What is a Database

A database is a structured collection of data that is often kept electronically on a computer system. Typically, a database is managed by a database management system (DBMS). Together, the...

9 minutes read.

Normalization in DBMS: 1NF, 2NF, 3NF, BCNF & 4NF with Examples

Normalization is a technique of organizing the data in the database. It is a systematic approach which is used to remove or reduce data redundancy in the tables and remove the...

7 minutes read.

Advantages of B-Tree in DBMS

A self-balancing search tree is the B-Tree. It is assumed that everything is in the main memory in most other self-balancing search trees (such as AVL and Red-Black Trees). We must...

3 minutes read.

Characteristics of DBMS

Introduction to DBMS: A database management system (DBMS) is a software application that is designed to manage and organize data stored in a database. It is responsible for storing, retrieving, and...

3 minutes read.

Red-Black Tree Visualization in DBMS

Introduction to Red Black Tree A red-black tree is a self-balanced binary search tree with an extra bit per node, usually read as a color (red or black). The tree is...

4 minutes read.

Query optimization in DBMS

Choosing an effective execution strategy to execute a query is a process known as query optimization. After the decision-making process of query parsing, which determines how many distinct ways a given...

5 minutes read.

DBMS Joins: Inner, Outer, Natural and Self Join

Joins are the combination of related tuples from the two different relations or tables into a single type. It is similar to the Cartesian product except the fact that in Cartesian product operation,...

4 minutes read.

Constraints in Database Management System

In a database management system, certain constraints are applied while performing any operation on the database to ensure that the integrity and quality of the data are maintained throughout the...

4 minutes read.

DBMS Examples

Introduction to DBMS A database management system (DBMS) is a software application that is designed to manage and organize data stored in a database. It is responsible for storing, retrieving, and...

4 minutes read.

Data Models in DBMS

Data Models in DBMS Data models are the models explaining the logical structure of the database systems. They describe the entities, attributes, and the relationship among the data elements of the...

8 minutes read.

Advantages of Database Management System in DBMS

A database management system (DBMS) is a software tool that provides an interface for managing data stored in a database. Some advantages of using a DBMS include: data integration, data...

3 minutes read.

Components of DBMS

The database management system (DBMS) represents an essential tool for processing data within effectively structured structures. The database management system consists of important components that work together to maintain the...

6 minutes read.

Advantages of DBMS

A Database Management System (DBMS) is a collection of programs which lets the end-users to manage and control the database. Database systems use query language for accessing, storing, and maintaining the...

3 minutes read.

Concurrency Control Protocols

Concurrency Control Protocols Concurrency control protocols ensure the atomicity, serializability and isolation of the concurrent transactions. The Concurrency control protocols can be broadly classified into the following categories: Lock Based ProtocolTimestamp protocol Lock Based Protocol In this protocol,...

5 minutes read.

ER Diagram for Banking System in DBMS

Entity Relationship Diagram Entity Relationship Diagrams, or ER Diagrams for short, are diagrams that show the relationships among entity sets that are stored in databases. Alternatively said, ER diagrams assist in...

3 minutes read.

Specialization in DBMS

Specialization in DBMS In the database management system, specialization breaks the higher-level entity into two or more than two lower entities. The main motive of this concept is to share the...

2 minutes read.

Data Abstraction in DBMS

Introduction Data abstraction is a fundamental concept in database management systems (DBMS). It refers to the process of hiding the details of how data is stored and retrieved from the user,...

3 minutes read.