January 8th, 2009

Introduction to Column Functions, Part 1 of 3

Posted by admin in J. Column Functions

Built-in functions automate common processes and are identified either as column functions or as scalar functions.

Column functions (sometimes known as aggregate functions) perform an operation on all SELECTed rows of an entire column and returns a single value in the results table for each of the following:
> All rows in the table
> Only the rows specified in the WHERE clause
> The rows created by a GROUP BY are often used with a HAVING clause to filter the groups.
Column functions can only be in a SELECT or HAVING clause, not in a WHERE clause.

Column Functions:

SUM(expr) .... Summation of values in a column .... (Works with numeric data only)
AVG(expr) .... Average of values in a column ...... (Works with numeric data only)
MIN(expr) .... Minimum value in a column .......... (Character, numeric, or datetime)
MAX(expr) .... Maximum value in a column .......... (Character, numeric, or datetime)
COUNT(expr) .. Count the number of non-null rows .. (Works with all data)
COUNT(*) ..... Count the total number of rows ..... (Works with all data)

(expr) is usually a column name but can be a function, literal, or a combination of these.
Your RDBMS system may provide other column functions, such as standard deviation.

Scalar functions perform an operation on a column value of each SELECTed row and returns a value for each row. Scalar functions can be used in a SELECT, WHERE, or HAVING clause and will be discussed later.

Comments are closed.

Sorry, the comment form is closed at this time.