Your browser does not support JavaScript. This help page requires JavaScript to render correctly. Using Numeric Functions in Queries
Skip Headers
Previous
Previous
 
Next
Next

Using Numeric Functions in Queries

Numeric functions accept numeric input and return numeric values. Each numeric function returns a single value for each row that is evaluated. The numeric functions that SQL supports are listed and described in Oracle Database SQL Language Reference.

The query in the following example uses the numeric function ROUND to display the daily pay of each employee in department 100, rounded to the nearest cent.

Rounding Numeric Data

SELECT LAST_NAME,
ROUND (((SALARY * 12)/365), 2) "Daily Pay"
FROM EMPLOYEES
WHERE DEPARTMENT_ID = 100
ORDER BY LAST_NAME;

Result:

LAST_NAME                  Daily Pay
------------------------- ----------
Chen                          269.59
Faviet                        295.89
Greenberg                     394.52
Popp                          226.85
Sciarra                       253.15
Urman                         256.44
 
6 rows selected.

The query in the following example uses the numeric function TRUNC to display the daily pay of each employee in department 100, truncated to the nearest dollar.

Truncating Numeric Data

SELECT LAST_NAME,
TRUNC (((SALARY * 12)/365), 2) "Daily Pay"
FROM EMPLOYEES
WHERE DEPARTMENT_ID = 100
ORDER BY LAST_NAME;

Result:

LAST_NAME                  Daily Pay
------------------------- ----------
Chen                             269
Faviet                           295
Greenberg                        394
Popp                             226
Sciarra                          253
Urman                            256
 
6 rows selected.

Related Topics

Oracle Database SQL Language Reference

Using Operators and Functions in Queries