# SQL Server ROUND() Function

by Dinesh Thakur Category: SQL Functions

The ROUND function allows you to round any numeric value. The general format is:

```ROUND (NumericValue, DecimalPlaces)
```

The NumericValue argument can be any positive or negative number, with or without decimal places, such as 712.863 or -42.

The DecimalPlaces argument is trickier. It can contain a positive or negative integer, or zero. If DecimalPlaces is a positive integer, it means to round to that many decimal places. If DecimalPlaces is zero, it means that you want no decimal places.

If DecimalPlaces is a negative integer, it means to round to that number of positions to the left of the decimal place. The following chart shows how the number 712.863 is rounded, with different values for the DecimalPlaces argument:

ROUND Function Expression                Resulting Value

ROUND (712.863, 3)                                          712.863

ROUND (712.863, 2)                                          712.86

ROUND (712.863, 1)                                          712.9

ROUND (712.863, 0)                                          713

ROUND (712.863, -1)                                         710

ROUND (712.863, -2)                                         700

What if you wanted the value of pi rounded to only two decimal places? Simple. You merely create a composite function with the PI and ROUND functions. You would first use the PI function to get the initial value and then apply the ROUND function to round it to two decimal places. The following statement returns a value of 3.14:

```SQL > SELECT ROUND(PI(), 2)
```
Related Articles of SQL

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles