background image
<< Returning a Location of a Substring | Using Character Functions >>
<< Returning a Location of a Substring | Using Character Functions >>

Using Built-In and Aggregate Functions

Retrieving Data with Queries
2-14 Oracle Database 2 Day Developer's Guide
Example 2­16 Use Quoted Alias Columns
SELECT first_name "First", last_name "Last", hire_date "Date Started"
FROM employees
ORDER BY last_name;
The results of the query appear.
First Last Date Started
-------------------- ------------------------- -------------------------
Ellen Abel 11-MAY-96
Sundar Ande 24-MAR-00
Mozhe Atkinson 30-OCT-97
...
107 rows selected
Using Built-In and Aggregate Functions
SQL arithmetic operators and other build-in functions allow you to perform
calculations directly on data stored in the tables.
Using Arithmetic Operators
Oracle Database SQL supports the basic arithmetic operators, such as the plus sign (
+
)
for addition, the minus sign (
-
) for subtraction, the asterisk (
*
) for multiplication, and
the forward slash (
/
) for division. These are evaluated according to standard
arithmetic rules of evaluation order.
In
Example 2­17
, the result set show the salary earned by employees who are eligible
for commission earnings, in order of the hire date.
Example 2­17 Evaluating an Arithmetic Expression
SELECT first_name "First", last_name "Last", salary * 12 "Annual Compensation"
FROM employees
WHERE commission_pct IS NOT NULL
ORDER BY hire_date;
The results of the query appear.
First Last Annual Compensation
-------------------- ------------------------- ----------------------
Janette King 120000
Patrick Sully 114000
Ellen Abel 132000
...
35 rows selected
Using Numeric Functions
Oracle Database has many numeric functions for manipulating numeric values, such
as
ROUND
for rounding to a specified decimal or
TRUNC
for truncating to a specified
decimal. These functions all return a single value for each row that is evaluated.
Example 2­18
shows how to determine daily pay, rounded off to the nearest cent.
See Also:
Oracle Database SQL Language Reference for information on all
available SQL functions