Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
i have a problem in rounding. i tried many things but couldnt find a solution.
this is with sql server 2012

i have to round 0.105 to 100 and 15.750 as 15.750 but when tried the below query it is not working


SELECT ROUND(cast(0.105 as decimal(6,3)),1) as roundof
SELECT ROUND(cast(15.750 as decimal(6,3)),1) as roundof


pls any solution

thanks in advance

Nirmala Devi

What I have tried:

SELECT ROUND(cast(0.105 as decimal(6,3)),1) as roundof
SELECT ROUND(cast(15.750 as decimal(6,3)),1) as roundof
Posted
Updated 25-May-21 20:22pm

1 solution

Quote:
i have to round 0.105 to 100 and 15.750 as 15.750
You can't round 0.105 to 100 - you'd have to round it to two decimal places, then multiply that by 100, which would mean the second value became 1,575 not 15.75

You need to think about your data, and work out exactly what you are trying to do, and why - I'm not sure that either your examples are right, or that you have looked at the data you need to process!
 
Share this answer
 
Comments
Nirmala Saravanan 26-May-21 2:25am    
this is my data. Actually a sales report .
OriginalGriff 26-May-21 2:53am    
Then you need to think about exactly what you want to do!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900