Results 1 to 4 of 4
  1. #1
    Pastor Del is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    6

    counting unique entries

    I have 2 linked tables, tblPN & tblReceivedDate. tblPN has field PN and tblReceivedDate has field [Received Date]. The tables are used to record the receipt of different part numbers and the date they received. I want to use a query to count how many times a part number is received. The catch is that I only want to count a part once even if it is received more than once on the same date. With the data in the attached DB the count for PN 123 would be 5.



    Can someone show me how to configure the query to do what I need to do?
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Try:

    Query1
    SELECT tblPN.PN, tblReceivedDate.[Received Date]
    FROM tblPN LEFT JOIN tblReceivedDate ON tblPN.PN_ID = tblReceivedDate.PN_ID
    GROUP BY tblPN.PN, tblReceivedDate.[Received Date];

    Query2
    SELECT Query1.PN, Count(Query1.[Received Date]) AS [CountOfReceived Date]
    FROM Query1
    GROUP BY Query1.PN;

    All in one:
    SELECT Query1.PN, Count(Query1.[Received Date]) AS [CountOfReceived Date]
    FROM (SELECT tblPN.PN, tblReceivedDate.[Received Date]
    FROM tblPN LEFT JOIN tblReceivedDate ON tblPN.PN_ID = tblReceivedDate.PN_ID
    GROUP BY tblPN.PN, tblReceivedDate.[Received Date]) AS Query1
    GROUP BY Query1.PN;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Pastor Del is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    6
    I'm wondering if there is a way to get the count using DCount.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Could use DCount referencing Query1.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 8
    Last Post: 10-22-2013, 05:08 PM
  2. Replies: 5
    Last Post: 02-29-2012, 11:56 AM
  3. Counting Entries
    By adams.bria in forum Queries
    Replies: 6
    Last Post: 08-26-2011, 10:41 AM
  4. Finding and counting (not records but entries)
    By gpbanseo in forum Queries
    Replies: 3
    Last Post: 07-14-2011, 04:35 AM
  5. Calculation on unique entries
    By cjbuechler in forum Programming
    Replies: 3
    Last Post: 06-24-2010, 09:47 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