Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

ROUND function

Syntax

ROUND( number, length [,operation_type] )

Description

The scalar function rounds number to length decimal places.

If value of length is positive, number is rounded to the number of decimal places specified by length.

If length is negative, number is rounded on the left side of the decimal point, as specified by the positive value of length.

Arguments

  • number - This is an expression of an exact numeric or approximate numeric data type.
  • length - This is the precision or number of digits to which number is to be rounded. The argument value must be of data type TINYINT, SMALLINT or INTEGER.
  • operation_type - This is the type of operation - rounding or truncation - to perform. The argument value must be of type TINYINT, SMALLINT or INTEGER. If the argument is omitted or has a value of 0 (default), number is rounded. If a value other than 0 is specified, number is truncated.

Example

SELECT price, ROUND(price, 1), ROUND(price, -1)

FROM custorder;

PRICE ROUND(PRI ROUND(PRI

----- --------- ---------

1546.56 1546.60 1550.00

SELECT price, ROUND(price, 1, 1), ROUND(price, -1, 1)

FROM custorder;

PRICE ROUND(PRI ROUND(PRI

----- --------- ---------

1546.56 1546.50 1540.00

TOCIndex