Functions

All of the database aspects on this site can be used in a variety of database systems and this is intentional. You may recall from the ANSI standard section that most databases support the standard that was created in 1992; and in technology standards, that is ages...

Basic Math Functions

We can use some of the simple math functions—Min, Max, AVG, and SUM—as basic examples of functions we can use in our queries. Each uses the same format and you will notice we only have one column in our select query. I have also used an alias in each example query...

Min Function

We use the MIN () function to determine the smallest amount or number in a column. While there may be more than one row with the smallest number, only one row will be returned. Select MIN (MonthsWithOwner) AS LeastTimeWithOwner FROM Cat; OUTPUT LeastTimeWithOwner...

Max Function

We use the MAX () function to determine the largest amount or number in a column. While there may be more than one row with the largest number, only one row will be returned. Select MAX (MonthsWithOwner) AS MostTimeWithOwner FROM Cat; OUTPUT MostTimeWithOwner...

Avg Function

We use the AVG () function to determine the average of all the values in a column. These examples use the columns MonthsWithOwner and OwnerAge Select AVG (MonthsWithOwner) AS AvgTimeWithOwner FROM Cat; OUTPUT AvgTimeWithOwner —————- 37 (1...

Sum Function

We use the SUM () function to determine the total value of all the rows in a column. This example uses MonthsWithOwner. Select SUM (MonthsWithOwner) AS 'Total Months of Cat Ownership' FROM Cat; OUTPUT MonthsWithOwner —————— 10055 (1...