SQL - AGGREGATE FUNCTIONS

The following are the most commonly used SQL aggregate functions:

  • AVG – calculates the average of a set of values.

  • COUNT – counts rows in a specified table or view.

  • MIN – gets the minimum value in a set of values.

  • MAX – gets the maximum value in a set of values.

  • SUM – calculates the sum of values.

AVG

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

SYNTAX

EXAMPLE

Let’s consider a demo database and table.

Figure 29.2. AGGREGATE QUERY & OUTPUT

Figure 29.1. Select * from SalaryInfo;

 
 

COUNT

The COUNT () function counts the number of rows that matches a specified condition.

SYNTAX

EXAMPLE

Figure 29.3. COUNT QUERY & OUTPUT

MIN

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

SYNTAX

EXAMPLE

Figure 29.4. MIN QUERY & OUTPUT

 
 

MAX 

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

SYNTAX

EXAMPLE

Figure 29.5. MAX QUERY & OUTPUT

©2020 by Pavan Lalwani. 

  • Udemy
  • Facebook
  • Twitter
  • YouTube
  • Linkedin