i wrote a scalare function-
select name,id
from tableName
where function1(id) / function2(id)>100
but sometimes function2 returns zero so im getting a divide by zero exception.
how can i solve this problem?
thanks in advanced
Printable View
i wrote a scalare function-
select name,id
from tableName
where function1(id) / function2(id)>100
but sometimes function2 returns zero so im getting a divide by zero exception.
how can i solve this problem?
thanks in advanced
add a condition to check that first - if function2 returns 0 and apply an AND condition between 2 where clause conditions.. if the first comes out false.. it should probably not check the second condition.. and hence ... see if that works..
what db system are you on? Hope this helps. Regards.
but how can i add a condition to a "where" ?
im using sql-server
Use two queries. First do "select function2(id) from TableName" test the value. If the value returned is zero do not continue to query "select name,id from tableName where function1(id) / function2(id)>100".Quote:
Originally Posted by ppl1
ok thanks for the help