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 can I make this work? I'm still getting nothing when I run the query.
 
If you expect null values in one of the queries you need to outer join not
inner join. Inner join will only produce results when the join value appears
in both tables or queries.
 

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