Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

Display a Rounded Number With a Specific Scale

Jim_KnicelyJim_Knicely Administrator
edited January 2019 in Tips from the Team

The Vertica ROUND function rounds a value to a specified number of decimal places, retaining the original precision and scale. Fractions greater than or equal to .5 are rounded up. Fractions less than .5 are rounded down (truncated).


dbadmin=> SELECT ROUND(12345.678901726198736271, 2) AS c_rounded;
(1 row)

If you’d prefer not to retain the original scale and have the scale of the result be a specific number of decimal places, then explicitly cast the expression to a NUMERIC instead.

dbadmin=> SELECT 12345.678901726198736271::NUMERIC(25, 2) AS c_rounded;
(1 row)

Helpful Links:

Have fun!

Sign In or Register to comment.

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.