Math Equation issue when data is missing.

I have no better idea how to describe it in the name as I do in a Google search.

**Background:** I am rewriting part of an ASP classic app into crystal reports using my own SQL. The app used declarations and such to create 4 different sums from fields from 4 different tables and then the final total I want comes from a mathematical string using those four sums. (PL SQL in Toad for Crystal XI)

**Result:** I created a whole PL SQL 'Script' using "WITH" rather than sub-queries to create the four sums (1 sum per table) and then the final SELECT does the math using those 4 sums.

**Problem:** My test member is only in 3 of the tables. The first 3 sums work fine (mathematically) and I get the sum I want. However it includes action on the sum of the 4th table which they are not in. As soon as it reaches the fourth table, rather than see it as 0.00, it crashes and gives me no return at all including the member ssn.

Basically this:

Code:

`SELECT`

reinstatementsum + claimsum - (indebtpaidsum * -1) + *indebtadjustsum* AS totalindebtedness

FROM totalreinstatement, totalclaim, totalindebtpaid, totalindebtadjust

reinstatementsum + claimsum - (indebtpaidsum * -1) returns what I want, $23529.68

I would need "indebtadjustsum" to return 0.00 or something if the ssn in question is not a member of the table it draws from.

Code:

`SELECT`

reinstatementsum + claimsum - (indebtpaidsum * -1) + *0.00* AS totalindebtedness

FROM totalreinstatement, totalclaim, totalindebtpaid, totalindebtadjust

Right now it does the math and then drops it and returns an empty row just like when I query the table for the SSN, it returns nothing.

In theory, any one member could 'not be in' any of those tables in any mix.

Does anyone have any ideas how I can deal with this? I always fall back into coding like the app does with IF or OR statements. But I am lost how to do it with SQL.

I could use 4 different statements and do the math with Crystal formulas but the office prefers SQL and I need or formula to suppress the result under certain conditions and I would not know how to use a "Suppress IF" in the formula I am doing the math in. So I would appreciate an SQL answer if there is any.

Much Obliged, Cheers!