Omnidex SQL Function: ROUND

Description

The ROUND function returns a numeric expression rounded to a specified number of decimal places. If the value specified by n is positive and longer than the digits after the decimal point, 0 is added after the fraction digits. If the value specified by n is negative and larger than or equal to the digits before the decimal point, 0.00 is returned.

Syntax

ROUND(numeric_expression [, n])

numeric_expression

Required. Any expression that returns a numeric expression.

n

Optional. n is an integer indicating the number of digits to the right of the decimal. The default is 0.

Example

Example 1: Column rounded to next higher integer

> select latitude, round(latitude) from countries;

LATITUDE                          ROUND(COUNTRIES.LATITUDE)
--------------------------------  --------------------------------
                       42.500000                         43.000000
                       24.000000                         24.000000
                       33.000000                         33.000000
                       17.049999                         17.000000
                       18.209999                         18.000000
                       41.000000                         41.000000
                       40.000000                         40.000000

Example 2: Column rounded to a set number of decimal places

Note that floating point values cannot represent ever value, and the values shown below are as close as floating point values can represent.

> select latitude, round(latitude, 1) from countries;

LATITUDE                          ROUND(COUNTRIES.LATITUDE,1)
--------------------------------  --------------------------------
                       42.500000                         42.500000
                       24.000000                         24.000000
                       33.000000                         33.000000
                       17.049999                         17.000000
                       18.209999                         18.200001
                       41.000000                         41.000000
                       40.000000                         40.000000

Additional Resources

See also:

 
Back to top
dev/sql/functions/round.txt ยท Last modified: 2016/10/15 04:48 by doc