Rounding numbers in SQL

D

Dirk Goldgar

Mario said:
How to round the numbers in SQL language

4.2 --> 4
4.7 --> 5
4.5 --> 5

In Access 2000 and later versions, there is a built-in Round() function
that you can use in Access SQL, but it may not give you exactly what you
want in some cases. It uses "banker's rounding", which means that in
the .5 cases it rounds to the nearest even number. So you get this:

Round(4.2) --> 4
Round(4.7) --> 5
Round(4.5) --> 4
Round(5.5) --> 6

The idea is that this evens out the rounding error, minimizing any bias.
If this is not what you want, if you want to round all .5 cases up, then
you have to use your own rounding function such as that posted here:

http://www.mvps.org/access/modules/mdl0054.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top