Arithmetic Operation - Division in Cero

ennrike

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 3, 2010
Messages
25
Hi,

I have a query where I am making an arithmetic operation:

SELECT * FROM MyTable WHERE HrsAct / HrsPlan > 1 AND USER = "John"

It works sometimes, the problem happen when HrsPlan = cero.

I tried to do:

SELECT * FROM MyTable WHERE HrsPlan > 0 AND HrsAct / HrsPlan > 1 AND USER = "John"

But I still get the error Overflow because I am dividing in cero.

How can I perform this query without having Overflow error?

Thanks,
 
Will this work? What do you want to see?

SELECT (HrsAct / HrsPlan) FROM MyTable WHERE HrsPlan > 0 AND USER = "John"
 
The operation "HrsAct / HrsPlan" will calculate the percentage of overloaded working orders. The point here is that in the query I have an aritmetic operation that gives me an error if I do "4.5 / 0". The overload error.

How can I handle this exception in a query?

By the way HrsAct and HrsPlan are doubles.

Thanks,
 
The point here is that in the query I have an aritmetic operation that gives me an error if I do "4.5 / 0". The overload error.
Code:
SELECT * FROM MyTable WHERE iif(HrsPlan = 0, 0, HrsAct / HrsPlan) > 1 AND USER = "John"
 
It looks that it only works for "integers" if I use doubles it does not work ...
 
Code:
SELECT * FROM MyTable WHERE iif(HrsPlan = 0, 0, CDbl(HrsAct) / CDbl(HrsPlan)) > 1 AND USER = "John"
 

Users who are viewing this thread

Back
Top Bottom