Database Reference
In-Depth Information
Most SQL implementations support the following types of functions:
■
Text functions are used to manipulate strings of text (for example,
trimming or padding values and converting values to upper- and
lowercase).
■
Numeric functions are used to perform mathematical operations on
numeric data (for example, returning absolute numbers and performing
algebraic calculations).
■
Date and time functions are used to manipulate date and time values
and to extract specific components from these values (for example,
returning differences between dates and checking date validity).
■
System functions return information specific to the DBMS being used
(for example, returning user login information or checking version
specifics).
You've already seen an example of text-manipulation functions in the last
chapter—the
RTrim()
function was used to trim white space from the end
of a column value. Here is another example, this time using the
Upper()
function:
▼
Input
SELECT vend_name, UPPER(vend_name) AS vend_name_upcase
FROM vendors
ORDER BY vend_name;
▼
Output
+----------------+------------------+
| vend_name | vend_name_upcase |
+----------------+------------------+
| ACME | ACME |
| Anvils R Us | ANVILS R US |
| Furball Inc. | FURBALL INC. |
| Jet Set | JET SET |
| Jouets Et Ours | JOUETS ET OURS |
| LT Supplies | LT SUPPLIES |
+----------------+------------------+