Immortal
Immortal

Reputation: 1180

How to round off numbers in SQL Server database

I have a column (named PercentageDifference) with numbers that have decimal places as shown below:

PercentageDifference

1.886792452830100
2.325581395348800
2.758620689655100
-3.689320388349500
-0.284900284900200
0.400000000000000

I want a query to round off the numbers to the nearest 10 and then leave 2 decimal places. Here is the output am looking for:

PercentageDifference
    1.89
    2.33
    2.76
   -3.69
   -0.28
    0.40

I have tried to use the ROUND function but its not giving me the expected results:

select round([Percentage Difference], 2, 1) from Table

How can this be achieved?

Upvotes: 0

Views: 75

Answers (1)

Ruslan K.
Ruslan K.

Reputation: 1981

You need only CAST:

SELECT CAST([Percentage Difference] AS decimal(19,2)) FROM Table;

Upvotes: 2

Related Questions