round(numeric, integer) — Round to a number of decimal places

Last updated: 2026-11-04

round(numeric, integer) — Round to a number of decimal places

round() rounds a value to the given number of decimal places, or to a whole number when the second argument is omitted. Combined with numeric it is exact decimal arithmetic with none of the binary floating-point representation error; applied to double precision it instead uses banker's rounding, so a .5 rounds to the nearest even number.

Kindfunction
Example LanguageSQL

📝 Syntax

round(value numeric, scale integer) → numeric
round(value double precision) → double precision

⚙️ Parameters

value numericThe value to round. Type numeric or double precision.
scale integerHow many decimal places to keep; when omitted it is treated as 0, i.e. rounding to a whole number. Type integer.

Returns:numeric — the rounded value; a numeric input returns numeric and a double precision input returns double precision.

▶ Example

Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.

Output:

 id |   price | round_2 | round_0
----+---------+---------+---------
  1 | 19.9950 |   20.00 |      20
  2 |  2.3450 |    2.35 |       2
  3 |  2.5000 |    2.50 |       3
(3 rows)

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QIs round(2.5) 2 or 3?
AIt depends on the type: numeric gives 3 (half away from zero) while double precision gives 2 (half to even). For money, cast explicitly to numeric.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏