开发者

Cast as decimal not giving me correct results

I get a result of 0.00000 from the following cast

Secs_in_month = 2592000
total_fault_time_sum = 99

cast(((Secs_in_Month - total_fault_time_sum) / Secs_in_Month) as decimal(18,5)) AS availability

the result should be 0.99996

any ideas on what I am doing wrong here ?

Many开发者_开发知识库 thanks


Cast it before division:

cast((Secs_in_Month - total_fault_time_sum) as decimal(18,5)) / Secs_in_Month AS availability

Otherwise, you're still doing integer division, and just casting the result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜