Subject  division by zero 

Author  Peter Lee 
Post date  20040318T08:26:46Z 
Hello Everybody,
We are getting 'Arithmatic overflow or division by zero has
occurred. arithmetic exception, numeric overflow or string truncation'
from the following query (running it through IBExpert, FB1.5).
We are fairly sure that one of the divisions for prac_percent and
test_percent are causing the problem. Is there any way to get around this
if the sum(g_stats.prac_attempted) or sum(g_stats.test_attempted) are zero?
I haven't bothered posting the entire query, but am happy to do so if need be!
Thanks,
Peter Lee
===
SELECT g_user.login_name,
g_class.name,
g_syllabus.syllabus_name,
g_topics.topic_name,
g_level.level_name,
g_level.level_seq_num,
sum(g_stats.prac_correct) as prac_correct,
sum(g_stats.prac_attempted) as prac_attempted,
sum(g_stats.test_correct) as test_correct,
sum(g_stats.test_attempted) as test_attempted,
sum(g_stats.prac_correct) * 100 / sum(g_stats.prac_attempted) AS
prac_percent,
sum(g_stats.test_correct) * 100 / sum(g_stats.test_attempted) AS
test_percent

Peter Lee Mobile: +61 412 011 174 ptle@...

Rising Software Australia Pty. Ltd. http://www.risingsoftware.com/
Publishers of 'Auralia'  Ear Training and 'Musition'  Theory Training
Ph: +61 3 9481 3320 FAX: +61 3 9481 3380 USA Freecall: 1 888 667 7839
We are getting 'Arithmatic overflow or division by zero has
occurred. arithmetic exception, numeric overflow or string truncation'
from the following query (running it through IBExpert, FB1.5).
We are fairly sure that one of the divisions for prac_percent and
test_percent are causing the problem. Is there any way to get around this
if the sum(g_stats.prac_attempted) or sum(g_stats.test_attempted) are zero?
I haven't bothered posting the entire query, but am happy to do so if need be!
Thanks,
Peter Lee
===
SELECT g_user.login_name,
g_class.name,
g_syllabus.syllabus_name,
g_topics.topic_name,
g_level.level_name,
g_level.level_seq_num,
sum(g_stats.prac_correct) as prac_correct,
sum(g_stats.prac_attempted) as prac_attempted,
sum(g_stats.test_correct) as test_correct,
sum(g_stats.test_attempted) as test_attempted,
sum(g_stats.prac_correct) * 100 / sum(g_stats.prac_attempted) AS
prac_percent,
sum(g_stats.test_correct) * 100 / sum(g_stats.test_attempted) AS
test_percent

Peter Lee Mobile: +61 412 011 174 ptle@...

Rising Software Australia Pty. Ltd. http://www.risingsoftware.com/
Publishers of 'Auralia'  Ear Training and 'Musition'  Theory Training
Ph: +61 3 9481 3320 FAX: +61 3 9481 3380 USA Freecall: 1 888 667 7839