A database function is a named SQL operation that performs a predefined calculation or other action. Like a spreadsheet’s SUM formula, it can calculate, extract, combine, convert, or format values. section 12.0 section 12.1
Call a function by writing its name followed by parentheses containing a column, variable, or other value. Functions can appear in queries that select or filter data. section 14.0 section 14.2.1
Uppercase customer names
To display California customers with both their stored names and uppercase versions, apply UPPER to each name column and assign readable aliases. section 14.2.1
SELECT
FirstName,
LastName,
UPPER(FirstName),
UPPER(LastName)
FROM customer
WHERE State = 'CA';
This query demonstrates applying a function to selected columns while filtering rows with a WHERE condition. section 14.2.1
Common jobs for database functions include:
- Calculate totals, minimums, maximums, and averages across a range of values. section 12.1
- Extract parts of dates and times, such as the year, month, day, hour, minute, or second. section 14.3
- Change strings and values, including converting text to uppercase or lowercase and converting values into new forms. section 15.2 section 14.2.1
Use functions thoughtfully on large data sets: they may read every value in a range and consume additional server resources. Function names and syntax also vary among relational database systems. section 14.1.1 section 14.1.2


