Skip to content
Advertisement

SQL rounding does not appear to work as expected

I have the following SQL query.

When this is run it produces the following Result;

enter image description here

All of the fields in the tables from which the query is getting it’s information (with the obvious exception of the dates) are defined as either Money or Decimal types.

In reality the Box4 figure ought to be 1351.17 and the box5 figure should be -1351.17

Why am I seeing the results above, and what I ought to do to get the result that I am expecting?

Advertisement

Answer

You never gave your DECIMAL types any precision past the decimal point. Hence, SQL Server is displaying the values with zero digits of precision past the decimal point, i.e. as integers.

Since you seem to want two decimal places of precision, try using this declaration:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement