

In this example, the original number is “72.12765”, the task is to round the given number up to three places. Let’s pass ‘3’ as a second parameter to the ROUND() function to get a number rounded up to three decimal places: SELECT ROUND(72.12765, 3)
POSTGRES ROUND TO 2 DECIMALS HOW TO
Let’s consider another example for a profound understanding of the ROUND() function.Įxample #4: How to Round a Numeric Value up to Three Decimal Points? The output verifies that the given number has been rounded up to two decimal places. The task is to round the given number up to two decimal places, so we will pass two parameters to the ROUND() function: SELECT ROUND(72.1214, 2) Therefore the ROUND() function rounded the given number upwards, i.e., 73.Įxample #3: How to Round a Numeric Value up to Two Decimal Points? This time, the fractional value was greater than 5 (i.e. Let’s take another example of the ROUND() function that accepts only one parameter to understand its working in a better way: SELECT ROUND(72.725) The fractional value was less than 5, so the given number was rounded downward.Įxample #2: How to Round a Number to an Integer Using ROUND() Function? The output verifies that the ROUND() function successfully rounded the given number to the nearest integral value. This example illustrates the working of the ROUND() function that accepts only one value/parameter: SELECT ROUND(72.125) While “n” is an optional parameter that determines the number of decimal points.Įxample #1: How to Use the ROUND() Function in PostgreSQL? Here, in this syntax, the “Number” represents a numeric value to be rounded. To avail the functionalities of the ROUND() function, you have to follow the below syntax: ROUND(Number ) How to Use ROUND() Function in PostgreSQL? This write-up will present detailed knowledge about the ROUND() function with the help of examples. For example, if the second parameter’s value is 2, then the given value will be rounded off to two decimal places. On the other hand, if the ROUND() function takes two parameters/values, then the second parameter specifies the number of decimal places. If the ROUND() function takes only one value, then it will skip the fractional part and round the given number to the nearest integral value. PostgreSQL offers a ROUND() function that takes either one or two arguments/values. Rounding off a number up to specific decimal places is a very common task.
