totn MariaDB Functions

MariaDB: ROUND Function

This MariaDB tutorial explains how to use the MariaDB ROUND function with syntax and examples.

Description

The MariaDB ROUND function returns a number rounded to a certain number of decimal places.

Syntax

The syntax for the ROUND function in MariaDB is:

ROUND( number, [ decimal_places ] )

Parameters or Arguments

number
The number to round.
decimal_places
The number of decimal places rounded to. This value must be a positive or negative integer. If this parameter is omitted, the ROUND function will round the number to 0 decimal places.

Note

  • If decimal_places is a negative number, the ROUND function will make digits to the left of the decimal place 0 values.
  • See also the FLOOR, CEIL, CEILING, and TRUNCATE functions.

Applies To

The ROUND function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB ROUND function examples and explore how to use the ROUND function in MariaDB.

For example:

SELECT ROUND(85.253);
Result: 85

SELECT ROUND(85.253, 0);
Result: 85

SELECT ROUND(85.253, 1);
Result: 85.3

SELECT ROUND(85.253, 2);
Result: 85.25

SELECT ROUND(85.253, -1);
Result: 90

SELECT ROUND(-85.253);
Result: -85