SQL Set Functions - dummies

By Allen G. Taylor

Part of SQL All-in-One For Dummies Cheat Sheet

Sometimes, the information that you want to extract from an SQL table doesn’t relate to individual rows but rather to sets of rows. SQL provides five set (or aggregate) functions to deal with such situations — COUNT, MAX, MIN, SUM, and AVG. Each function performs an action that draws data from a set of rows rather than from a single row:

COUNT Returns the number of rows in the specified table
MAX Returns the maximum value that occurs in the specified
MIN Returns the minimum value that occurs in the specified
SUM Adds up the values in a specified column
AVG Returns the average of all the values in the specified