The ROUND function accepts two numeric value expressions (n,m) as
arguments. The result is the first value expression n rounded to
m places to the right of the decimal point. The value expression
m can be negative to round off digits to the left of the decimal
point. The data type of m must be an unscaled numeric value
(tinyint, smallint, integer, or bigint). If omitted, m defaults
to zero. See the following example.
SQL> select avg (salary_amount)
cont> from salary_history
cont> where employee_id = '00164';
3.857350000000000E+004
1 row selected
SQL> select round (avg (salary_amount)) as SAL edit using 'sz(9).99'
cont> from salary_history
cont> where employee_id = '00164';
SAL
38574.00
1 row selected
Usage Notes
o The function ROUND for numeric values is supported as a native
function in Oracle Rdb.
o Fixed point values are truncated and rounded correctly.
Floating values, while supported by ROUND, may not always
return the expected results. Please review usage of ROUND in
such contexts.
o The result type for ROUND will match the data type of the
input source parameter.
o The implementation of ROUND for DATE values requires the use
of the OCI Services for Rdb library (also know as SQL*net for
Rdb). These functions will now accept DATE ANSI, TIMESTAMP and
DATE VMS values.
o Attempts to use ROUND on a database that is not setup for OCI
Services will receive errors similar to these:
SQL> select TRUNC (current_date) from rdb$database;
%RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist
-RDMS-F-BAD_SYM, unknown routine symbol - TRUN2
SQL> select ROUND (current_date) from rdb$database;
%RDB-E-OBSOLETE_METADA, request references metadata objects that no longer exist
-RDMS-F-BAD_SYM, unknown routine symbol - ROUN2
NOTE
The special functions ROUN2 and TRUN2 are internal
routines to deal with DATE types.
o ROUND supports the data types REAL, FLOAT and DOUBLE PRECISION
for both parameter and results. However, due to the imprecise
nature of floating point arithmetic this may cause unexpected
results. A value such as 4.185 will not round to 4.19 as
expected because the internal (and approximate) representation
of the number is something like 4.184999942780E+000 and
therefore does not appear to require rounding to the second
decimal place according to the rounding rules.
The following example shows this problem.
SQL> select cast(round (4.185,2) as integer(2)) from rdb$database;
4.18
1 row selected
SQL> select cast(round (4.175,2) as integer(2)) from rdb$database;
4.18
1 row selected
SQL>
NOTE
The result of a divide operation (/) or the AVG, STDDEV,
VARIANCE statistical functions are floating point values,
so applying TRUNC or ROUND to those results, even if
performed on integer sources, will also be affected by
the intermediate floating point type.
o If you use SQL to access older versions of Rdb (such as via
remote access) then SQL will revert to the previous behavior
and use the SQL functions provided by the SQL_FUNCTIONS
library.