I want to do a simple thing but it seems to be behaving not as i am expecting
I want to round number either up or down...
e.g: 4.3 should round to 4
4.7 should round to 5
when i use the round function like this:
83/17=4.88
round( 83/17 , 0 ) it gives the answer as 4...when i was expecting it to be 5...
i know there is a ceiling function...but depending on the value of the division sometimes i want it to round up and sometimes round down.
how can i do this?
hope this makes sense.
thanks
Think ive found the problem is nothing to do with round...
i think83/17 returns a truncated value of 4 not 4.88 as i wanted...
in that case how do i make it return a decimal value?
|||
this did the trick
round(Cast(83 as float)/17)
|||
Assign the value to a variable of type decimal(5,2) or numeric(5,2) not to integer.
Good luck.
No comments:
Post a Comment