round

Rounds a number to the nearest integer, with halfway values rounded away from zero.

Syntax

round(<expr>)

Arguments

ArgumentTypeDescription
<expr>floatInput value.

Returns

Returns float. Returns NULL if the input is NULL.

Usage notes

For an int or uint column, cast the value to float before calling this function.

Examples

Round a calculated percentage to one decimal place for a report.

VALUES ('web', 23, 80), ('mobile', 17, 60)
SELECT $0 AS channel, $1 AS purchases, $2 AS checkouts
SELECT channel, round(purchases / checkouts * 1000.0) / 10.0 AS conversion_pct
+---------+----------------+
| channel | conversion_pct |
+---------+----------------+
| web     | 28.8           |
| mobile  | 28.3           |
+---------+----------------+

Multiply the ratio by 1000 before rounding, then divide by 10 to get a percentage with one decimal place.