SQL Functions

While most scripts will SELECT information from a database and in a separate line perform operations upon it, it can be more efficient to let SQL handle some of these operations. In fact SQL has a whole series of functions to do such things as add columns, take averages, extract the largest value, et al.

There are two common types of functions, aggregate and scalar. An aggregate function is one which performs an operation on an entire column of information and returns one result. An important aspect of aggregate functions is that they ignore nulls within individual cells. Scalar uses individual cell data in series to produce output for an entire column. Within these types there are various categories of functions that work on numbers, characters, or dates, or simply fulfill a miscellaneous need.

Other types of functions include analytic functions, object reference, and model functions. While less common than aggregate and scalar, these can also be useful. Analytic functions are performed on a number of rows and can only be used in the ORDER BY clause.

The functions included here are not exhaustive. Various SQL vendors have proprietary functions, and like English, language is slowly evolving. In our list the functions have been tested in mySQL, but should work on the broad range of SQL languages.

In a separate folio we have included the SQL statements which form the basic structure of the language.

Next Page: AVG Function SQL

Interesting Pages