Friday, March 9, 2012

Divide by zero error SQL SERVER

Hi

Is there a way to prevent this error?

I'm getting it from query line:

10000 * (SELECT count(filial_cotacao) from negocios_cotacoes where filial_cotacao = cod_filial)) / (22 * 6 * (SELECT count(filial_cotacao) from negocios_cotacoes where filial_cotacao = cod_filial)),1) 'Atingimento Semestre'

Thanks a lot

I found out how, thanks:

CASE WHENcount(filial_cotacao) = 0 THEN 0 ELSE
(10000 * (SELECT count(filial_cotacao) from negocios_cotacoes where filial_cotacao = cod_filial)) / (22 * 6 * (SELECT count(filial_cotacao) from negocios_cotacoes where filial_cotacao = cod_filial))ENDAS 'Atingimento Semestre'

|||

In SQL Server 2005 the rules for ArithAbort and ArithIgnore have changed check the links below for details. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms184341.aspx

http://msdn2.microsoft.com/en-us/library/ms190306.aspx

No comments:

Post a Comment