tags:

views:

76

answers:

5

I have a number and I use ROUND() function in SQL :

SELECT ROUND(1.81999,2,1)

I want the result 1.82, not 1.81.
I don't know where my mistake is.

+2  A: 

mysql? just ROUND(...,2) work for me.

mysql> SELECT ROUND(1.81999,2);
+------------------+
| ROUND(1.81999,2) |
+------------------+
|             1.82 |
+------------------+
1 row in set (0.00 sec)

mysql>
S.Mark
I did it in sql-server2005
LIX
@LIX, ok, just don't use 3rd parameter in ROUND function, it could be trancating. so just try `round(1.81999,2)`
S.Mark
A: 

See Section "Round to truncate" of Round(Transact-SQL)

This probably depends on the SQL-Dialect you use.

stacker
+2  A: 

SELECT ROUND(1.81999,2,1) Will truncate the result. so the result is 1.81

use this to perform original rounding SELECT ROUND(1.81999,2).

Dinesh
+1  A: 

The answer is simple. you are specifying 1 in the Function command (3rd parameter of the ROUND() command.
a quote from MSDN about this parameter:
When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.

Just change that 1 at the end to a 0 or ommit it entirely and problem solved

TerrorAustralis
A: 

use thie query

select round(1.81999,2)

Manoj

Manoj Wadhwani