Testing if it is null will not help you much in the way you are doing, because if the value of working hours remains zero, you will still get division error by zero.
Most likely its function horas_uteis_trabalhadas
must be returning an integer or value less than 144000 and in sql server when dividing any value by an integer, it will always return an integer, which in your case will be zero.
What you can do, is test if the working hours work is greater than zero, I set an example using the case and make a cast
for float
:
with v1 as (
select
cast(dbo.horas_uteis_trabalhadas('01-11-2017','30-11-2017') as float) as horas,
cast(nullif(144000,null) as float) as valor,
count(f.SolID) as SolId
from tarefa f)
select iif(horas > 0, SolId / cast(horas/valor as float), 1) as [DPI]
from v1
are an initial date and end date field
– Renan Bessa
You intend to rent to how many decimal places?
– Marconi
7 equal as it is in query. decimal (7.1)
– Renan Bessa
thanks for the help @Marconi
– Renan Bessa