Division by zero error

Mike Hughes

Registered User.
Local time
Today, 19:04
Joined
Mar 23, 2002
Messages
493
I have the query below and keep getting "Division by Zero" error when I run it.
I'm looking for the percent of CURRENT PAID to the CURRENT DUE. There is one CASELOAD which has "0" CURRENT DUE AND "0" CURRENT PAID and I believe that might be what is causing the problem.
Can someone point me in the right direction? Thanks

SELECT
[14 TABLE].CASELOAD,
[14 TABLE].[CURR DUE],
[14 TABLE].[CURR PAID],
[14 TABLE].[ARR PAID],
SUM ([14 TABLE].[CURR PAID]/[14 TABLE].[CURR DUE]) AS [PERCENT PAID]

FROM [14 TABLE]
GROUP BY
[14 TABLE].CASELOAD,
[14 TABLE].[CURR DUE],
[14 TABLE].[CURR PAID],
[14 TABLE].[ARR PAID]
 
After the From line add
Code:
Where [CURR DUE] <> 0

Another way is to use an IIF statement.
Code:
IIF ([CURR DUE] <> 0, SUM([CURR PAID]/[[CURR DUE]), Null) AS [PERCENT PAID]
Where there is only one table you can leave out the table name.
Also recommend you stop using all capitals for fields and stop including spaces.
CurrentDue is a lot easier to read and enter.
 
One option would be to eliminate the row where the zero occurs with a parameter. Something like show me all the rows where so and so field is not zero...
 
Thanks to all
I went with GalaxiomAtHome-- "Where [CURR DUE] <> 0"
 

Users who are viewing this thread

Back
Top Bottom