Reputation: 25
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
Upvotes: 0
Views: 494
Reputation: 284806
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.
Upvotes: 5