background image
<< Using Built-In and Aggregate Functions | Concatenating Character Data >>
<< Using Built-In and Aggregate Functions | Concatenating Character Data >>

Using Character Functions

Retrieving Data with Queries
Querying and Manipulating Data 2-15
Example 2­18 Rounding off Numeric Data
SELECT first_name "First", last_name "Last",
ROUND(salary/30, 2) "Daily Compensation"
FROM employees;
The results of the query appear.
First Last Daily Compensation
-------------------- ------------------------- ----------------------
Steven King 800
Neena Kochhar 566.67
Lex De Haan 566.67
...
107 rows selected
Example 2­19
shows how to determine daily pay that is truncated at the nearest dollar.
Note that the
TRUNC
function does not round-up the value.
Example 2­19 Truncating Numeric Data
SELECT first_name "First", last_name "Last",
TRUNC(salary/30, 0) "Daily Compensation"
FROM employees;
The results of the query appear.
First Last Daily Compensation
-------------------- ------------------------- ----------------------
Steven King 800
Neena Kochhar 566
Lex De Haan 566
...
107 rows selected
Using Character Functions
Oracle Database includes an extensive list of character functions for customizing
character values.
These functions can change the case of a character expression to
UPPER
or
LOWER
,
remove blanks, concatenate strings, and extract or remove substrings.
Example 2­20
demonstrates how to change the character case of your expression. The
result set shows the results of
UPPER
,
LOWER
, and
INITCAP
functions.
Example 2­20 Changing the Case of Character Data
SELECT UPPER(first_name) "First upper",
LOWER(last_name) "Last lower",
INITCAP(email) "E-Mail"
FROM employees;
The results of the query appear.
First upper Last lower E-Mail
-------------------- ------------------------- -------------------------
STEVEN king Sking
See Also:
Oracle Database SQL Language Reference for information on numeric
SQL functions