Results 1 to 4 of 4
  1. #1
    jascraig is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Location
    Cincinnati, OH
    Posts
    2

    LEFT JOIN Breaks with Where Clause

    All,

    I know I'm missing something pretty simple here, but unfortunately Access SQL isn't my forte. Here's a quick description of the problem:
    I have two tables

    Author
    ID
    Author

    Report
    Author_ID
    ID
    Subj
    PubDate

    Not all authors will write reports.

    This query works properly:


    SELECT DISTINCTROW Author.Author, Count(Report.ID)
    AS [Count Reports]
    FROM Author LEFT JOIN Report ON Author.ID = Report.Author_ID
    GROUP BY Author.Author

    The query returns the count of reports written, and 0 if the Author has no reports in the report query.

    This query doesn't work:
    SELECT DISTINCTROW Author.Author, Count(Report.ID)
    AS [Count Reports]
    FROM Author LEFT JOIN Report ON Author.ID = Report.Author_ID
    WHERE Report.PubDate > #6/20/2010#
    GROUP BY Author.Author

    It only returns the positive non-zero counts from the Report table. No other authors are included.

    What am I missing?

    Thanks!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    SELECT DISTINCTROW Author.Author, Count(Report.ID)
    AS [Count Reports]
    FROM Author LEFT JOIN Report ON Author.ID = Report.Author_ID
    WHERE Report.PubDate > #6/20/2010# or report.pubdate is null
    GROUP BY Author.Author

  3. #3
    jascraig is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2010
    Location
    Cincinnati, OH
    Posts
    2
    Brilliant! I knew I was overlooking something way too easy. Thanks.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Please mark it as solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problem with Left Join & VB6
    By msrdjan1 in forum Queries
    Replies: 0
    Last Post: 03-30-2010, 01:48 AM
  2. Column Breaks
    By Pam Buckner in forum Reports
    Replies: 0
    Last Post: 03-08-2010, 02:34 PM
  3. Error using left join accessing 2 active connections
    By peterg2000 in forum Programming
    Replies: 0
    Last Post: 10-05-2009, 05:04 PM
  4. Program breaks after break was removed
    By Gene in forum Programming
    Replies: 3
    Last Post: 06-02-2009, 07:19 AM
  5. Update with LEFT JOIN
    By mcarthey in forum Access
    Replies: 1
    Last Post: 08-27-2008, 10:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums