-
February 25th, 2006, 04:11 AM
#1
help with a query
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
-
February 25th, 2006, 06:30 AM
#2
Re: help with a query
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.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
February 25th, 2006, 08:35 AM
#3
Re: help with a query
but how can i add a condition to a "where" ?
im using sql-server
-
February 25th, 2006, 09:56 AM
#4
Re: help with a query
Originally Posted by ppl1
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".
-
February 25th, 2006, 11:54 AM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|