SQL Aggregate Functions – SQL Tutorial | Software Testing Material

SQL Aggregate Functions:

In this post, we see SQL Aggregate functions in detail.

SQL aggregate functions return a single value, calculated from values in a column.

AVG() – This functions returns the average value
COUNT() – This functions returns the number of rows
MAX() – This functions returns the largest value
MIN() – This functions returns the smallest value
ROUND() – This functions rounds a numeric field to the number of decimals specified
SUM() – This functions returns the sum

Let’s see one by one in detail.

SQL AVG() Syntax:

Example:

Here I have written two statements to show you the output of complete table and output of average runs.

Copy both the statements as mentioned in the below screenshot and execute it to see the results.

SQL Aggregate Functions Averge

SQL COUNT() Function:

Example:

SQL Aggregate Functions Count

SQL MAX() Function:

SQL MIN() Function:

 

Example:

SQL Aggregate Functions Max Min

SQL ROUND() Function:

 

Example: If the value is 250.55 and you want to show just 250 then you could pass decimals parameter as 0. Same way if you want to show 250.5 then you could pass decimals value as 1.

SQL SUM() Function:

 

Example:

SQL Aggregate Functions Sum

In the next tutorial, we will learn STRING FUNCTIONS in SQL

Check out the complete SQL Tutorial by clicking on below link:

SQL Tutorial – Complete

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap