Adding two queries when one is null

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

SELECT
IIf(IsNull(Sum([vend_div_vol]![vendvolume])),Sum([OPDS2_Div_Vol]![DivVolume]),IIf(IsNull(Sum([OPDS2_Div_Vol]![DivVolume])),Sum([vend_div_vol]![vendvolume]),Sum([vend_div_vol]![vendvolume])+Sum([OPDS2_Div_Vol]![DivVolume]))) AS Volume
FROM ((OPDS2_Div_Vol INNER JOIN Terminals_Chosen ON OPDS2_Div_Vol.Terminal =
Terminals_Chosen.Terminal_ID) INNER JOIN Months_Chosen ON OPDS2_Div_Vol.Month
= Months_Chosen.Month) INNER JOIN vend_div_vol ON
(Terminals_Chosen.Terminal_ID = vend_div_vol.SAPID) AND (Months_Chosen.Month
= vend_div_vol.MONTH);

How come this doesn't work? The problem is that OPDS2 doesn't have the
specified SAP_ID so there is no volume, but I want it to see that its null
and then just return the other part of the calculation. Please Help!
 
You aren't referencing the SAP_ID from OPDS so I don't see how that's an issue.

I still think your issue is that you need to OUTER join not inner join these
tables so that cases where there is no record on certain tables returns a
null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top