Interactive Online SQL Training
HOME News MS SQL Oracle DB2 Access MySQL PHP SQL Etc Scripts Links Forums DBA Talk
SQL Courses
Free Newsletters:

By submitting your information, you agree that sqlcourse2.com may send you SQLCourse2 offers via email, phone and text message, as well as email offers about other products and services that SQLCourse2 believes may be of interest to you. SQLCourse2 will process your information in accordance with the Quinstreet Privacy Policy.

Aggregate Functions


MIN returns the smallest value in a given column
MAX returns the largest value in a given column
SUM returns the sum of the numeric values in a given column
AVG returns the average value of a given column
COUNT returns the total number of values in a given column
COUNT(*) returns the number of rows in a table

Aggregate functions are used to compute against a "returned column of numeric data" from your SELECT statement. They basically summarize the results of a particular column of selected data. We are covering these here since they are required by the next topic, "GROUP BY". Although they are required for the "GROUP BY" clause, these functions can be used without the "GROUP BY" clause. For example:

SELECT AVG(salary)

FROM employee;

This statement will return a single result which contains the average value of everything returned in the salary column from the employee table.

Another example:

SELECT AVG(salary)

FROM employee

WHERE title = 'Programmer';

This statement will return the average salary for all employee whose title is equal to 'Programmer'


SELECT Count(*)

FROM employee;

This particular statement is slightly different from the other aggregate functions since there isn't a column supplied to the count function. This statement will return the number of rows in the employees table.


Use these tables for the exercises

Review Exercises

  1. Select the maximum price of any item ordered in the items_ordered table. Hint: Select the maximum price only.
  2. Select the average price of all of the items ordered that were purchased in the month of Dec.
  3. What are the total number of rows in the items_ordered table?
  4. For all of the tents that were ordered in the items_ordered table, what is the price of the lowest tent? Hint: Your query should return the price only.

Answers to these Exercises

Enter SQL Statement here:


SQL Course Curriculum
<<previous 1234567891011121314 next>>