ROUND

The ROUND function returns a number that is rounded to the specified number of places to the right or left of the decimal place.

numeric-expression-1
An expression that returns a value of any built-in numeric data type.

If expression-1 is a decimal floating-point data type, the DECFLOAT ROUNDING MODE will not be used. The rounding behavior of ROUND corresponds to a value of ROUND_HALF_UP. If you want a different rounding behavior, use the QUANTIZE function.

The argument can also be a character string or graphic string data type. The string input is implicitly cast to a numeric value of DECFLOAT(34).

numeric-expression-2

An expression that returns a value that is a built-in numeric, character string or graphic string data type. If the value is not of type INTEGER, it is implicitly cast to INTEGER before evaluating the function.

The absolute value of integer specifies the number of places to the right of the decimal point for the result if numeric-expression-2 is not negative. If numeric-expression-2 is negative, numeric-expression-1 is rounded to the sum of the absolute value of numeric-expression-2+1 number of places to the left of the decimal point.

If the absolute value of numeric-expression-2 is larger than the number of digits to the left of the decimal point, the result is 0. (For example, ROUND(748.58,-4) returns 0.)

If numeric-expression-1 is positive, a digit value of 5 is rounded to the next higher positive number. If numeric-expression-1 is negative, a digit value of 5 is rounded to the next lower negative number.

The result of the function has the same data type and length attribute as the first argument except that the precision is increased by one if the argument is DECIMAL and the precision is less than 31. For example, an argument with a data type of DECIMAL(5,2) results in DECIMAL(6,2). An argument with a data type of DECIMAL(31,2) results in DECIMAL(31,2).

Example 1:

The following example rounds the number available in the SALARYcolumn in the table EMPLOYEE.


SELECT ROUND(SALARY) FROM EMPLOYEE

The above example returns the following.


50000
20000

25000
75000
75000