views:

32

answers:

1

Hello

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

+5  A: 

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.

Matthew Flaschen