Oracle SQL

Oracle / PLSQL: FLOOR , CEIL , ROUND Function

Oracle / PLSQL: FLOOR Function

Description

The FLOOR function returns the greatest integer value greater than or equal to a number.

Syntax

FLOOR function in Oracle/PLSQL is:

FLOOR( number )

Parameters or Arguments

Number

The value is used to determine the largest integer value that is equal to or less than a number.

Returns

The FLOOR function returns an integer value.

Applies To

The FLOOR function can be used in the following versions of Oracle/PLSQL:

*Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let’s look at some Oracle FLOOR function examples and explore how to use the FLOOR function in Oracle/PLSQL.

For example:

FLOOR(5.9)
Result: 5
FLOOR(34.29)
Result: 34
FLOOR(-5.9)
Result: -6

Oracle / PLSQL: CEIL Function

Description

The Oracle/PLSQL CEIL function returns the smallest integer value that is greater than or equal to a number.

Syntax

The syntax for the CEIL function in Oracle/PLSQL is:

CEIL( number )

Parameters or Arguments

number

The value used to find the smallest integer value.

Returns

The CEIL function returns an integer value.

Applies To

The CEIL function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let’s look at some Oracle CEIL function examples and explore how to use the CEIL function in Oracle/PLSQL.

For example:

CEIL(32.65)
Result: 33
CEIL(32.1)
Result: 33
CEIL(32)
Result: 32
CEIL(-32.65)
Result: -32
CEIL(-32)
Result: -32

Oracle / PLSQL: ROUND Function (with numbers)

Description

The Oracle/PLSQL ROUND function returns a number rounded to a certain number of decimal places.

Syntax (with numbers)

The syntax for the ROUND function in Oracle/PLSQL is:

ROUND( number [, decimal_places] )

Parameters or Arguments

number

The number to round.

decimal_places

Optional. The number of decimal places rounded to. This value must be an integer. If this parameter is omitted, the ROUND function will round the number to 0 decimal places.

Returns

The ROUND function (as it applies to numbers) returns a numeric value.

Applies To

The ROUND function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example – with numbers

Let’s look at some Oracle ROUND function examples and explore how to use the ROUND function in Oracle/PLSQL.

For example:

ROUND(125.315)
Result: 125
ROUND(125.315, 0)
Result: 125
ROUND(125.315, 1)
Result: 125.3
ROUND(125.315, 2)
Result: 125.32
ROUND(125.315, 3)
Result: 125.315
ROUND(-125.315, 2)
Result: -125.32

 

About the author

shohal

Leave a Comment