Skip to content
SQLSimplified
numeric

ROUND()

Rounds a numeric value to a specified number of decimal places.

Description

ROUND rounds a numeric value to a given number of decimal places, using standard rounding rules (0.5 rounds up). It's most often used to clean up prices, averages, and other calculated values for display.

Syntax

ROUND(number, decimals)

Parameters

NameDescriptionOptional
numberThe numeric value or column to round.No
decimalsHow many digits to keep after the decimal point. A negative value rounds to the left of the decimal point (for example, to the nearest 10).Yes, defaults to 0

Return Type

ROUND returns a DOUBLE (or the same numeric type as the input), not a formatted string, so the result can still be used in further calculations.

Examples

Library (Books/Authors/Publishers)

Loading database engine...

Library (Books/Authors/Publishers)

Loading database engine...

ROUND with a negative decimals argument

ROUND(price, -1) rounds to the nearest 10 instead of the nearest decimal place. This is a lesser-known trick for bucketing numbers, like rounding prices to the nearest $10.

Common Mistakes

  • Confusing ROUND with truncation. ROUND(4.567, 1) gives 4.6, not 4.5, because it rounds rather than simply cutting off digits.
  • Assuming ROUND formats the number as text with trailing zeros. ROUND(4.50, 2) may display as 4.5 depending on the client, since the underlying value is still a number, not a formatted string with a fixed number of digits.
  • Forgetting the second argument. Omitting decimals typically rounds to a whole number, which may not be what you intended when you just wanted to trim a couple of digits.

See also: CAST, SUM, AVG.

Search

Search lessons, functions, examples, and practice problems