Data is Fun

Where data is fun.


June 06, 2020

Aggregate SQL Functions

Count
Sum
Avg
Max/Min

Examples:

Count

Count the number of records in a column or table. Examples:

  • Select count(*) from table;
  • Select count (column) from table;

Count (*) will give you count of all rows – even if some values are null. Counting the column won’t count the null ones

Sum

Sum, or add all the values in the column.

  • Select sum(column) from table;

Avg

Calculate the average.

  • Select avg (column) from table;

Max

Find the maximum/highest/ biggest #.

  • Select max(column) from table;

Min

Find the minimum/ smallest/lowest #.

  • Select min(column) from table;

Leave a Reply

Your email address will not be published. Required fields are marked *