0

Hi,

I need help in Rounding,

value >5 increases to 1.

Eg: 72.70 should Round to 73.0

Could anyone please help me.

Thanks in Advance. TDHelp

flag

2 Answers

0

I think double casting should do the trick for you:

select cast( cast(72.70 as decimal(2)) as decimal(3,1))

Result: 73.0

link|flag
Thanks a lot, this helped me a lot. The below thing worked instead of 3,1 select cast( cast(72.70 as decimal(2)) as decimal(4,1)) – TDHELP Jan 14 at 3:25
0

Rounding is the default behavior when casting to a lower precision decimal. For example:

select cast(72.7 as decimal(2))

Answer: 73
link|flag
Thanks for the reply, But I want in this format only 73.0 When I try in the query with decimal(2), I am getting Numeric overflow occured during computation. – TDHELP Jan 8 at 0:36
Try a larger number like decimal(10) then. – Carlos A. Ibarra Jan 9 at 23:24

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.