Query help - modify SQL to get records

G

Guest

I am using Office 2003 on Windows XP.

I have a query in the general design of the following (I have tried to
simplify it using generic terms - hopefully my "boil-down" below is rightly
presented):

SELECT Table1.Field1, Table2.Field2, Sum(Table2.Field3)
FROM Table3
INNER JOIN Table2 ON Table3.Field1 = Table2.Field1
INNER JOIN Table1 ON Table2.Field7 = Table1.Field7
GROUP BY Table1.Field1, Table2.Field2
HAVING Table2.Field1 >= " & dateBegin & " AND
Table2.Field1 <= " & dateEnding & ";"

The above query works fine except when Table2.Field1 (a date) has a record
for which there is no corresponding date in Table3. In that case, no record
is returned for that date.

Can someone please modify this SQL so that all dates specified by the
"Having" clause are returned from Table2 even though there is no
corresponding record (date) in Table3.

I hope this is clear enough, if not please post back. Thanks much in advance
for your assistance.
 
J

John Spencer

Change your INNER JOINS to RIGHT JOINS. That may be the solution to your
problem.
 

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

Top