|
-
Jul 22nd, 2004, 04:01 AM
#1
Thread Starter
Fanatic Member
Simple math issue
I have a database that supplies numbers for some math.
The math is of the form A plus B over C
A + B
------
C
However sometimes C is 0.
Therefore I need a formula that will work normally for all values greater than nothing but result in 0 when C is 0. Is this do able?
Thanks guys.
-
Jul 22nd, 2004, 04:15 AM
#2
-
Jul 22nd, 2004, 04:53 AM
#3
Thread Starter
Fanatic Member
Originally posted by manavo11
Have a system :
A+B
C , for C>0
0 , for C=0
I was hopeing that there was some formula with a bit of +1, -1 etc that would simply by pass div by zero... I hate editing the raw SQL as it is nested six selects deep.
-
Jul 22nd, 2004, 05:06 AM
#4
You'll need an equivalent of iif (instant if).
iif(c=0,0,(a+b/c))
either that or put the formula into a sub query with a linkable ID filtered on the c<>0.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 22nd, 2004, 07:43 AM
#5
Thread Starter
Fanatic Member
Originally posted by Ecniv
You'll need an equivalent of iif (instant if).
iif(c=0,0,(a+b/c))
either that or put the formula into a sub query with a linkable ID filtered on the c<>0.
Vince
Probably yes. I don't want to face what access does to nested queries when you open them back up... but yes at least you have illiminated non-options.
-
Jul 22nd, 2004, 06:31 PM
#6
Lively Member
Hmmm,
Well:
(1\(C+1)) + C
Results in 1 if C = 0, or C when C > 0.
But you now need a multiplier that = 0 when C = 0, or 1 when C <> 0.
Hmmm,
K = (1\(C+1))+C
So,
When C = 0, then K = 1
When C > 0, then K = C
So:
C/K = 0 when C = 0,
C/K = 1, when C > 0.
Therefore:
(C/K)*(A+B)/(K)
where
K = (1\(C+1))+C
hmmm,
Is that Right?
-Lou
Last edited by Something Else; Jul 22nd, 2004 at 06:35 PM.
-
Jul 26th, 2004, 03:34 AM
#7
Thread Starter
Fanatic Member
-
Jul 26th, 2004, 08:06 AM
#8
Thread Starter
Fanatic Member
I loved the math however smarty pants in the office next door may have jsut shown us all up "why not simply ignore all values of 0 and never use it as +0 and 0 not added is the same"
beasty!
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
|