Results 1 to 2 of 2
  1. #1
    PeakH is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Posts
    143

    Count Unique Records Only

    I have a table of Order Numbers (tblOrderConf) and a table of Order Details (tblOrderDetails). tblOrderDetails has a field [Seller] that can either be Company1 or Company2, so a single order can have items sold by both company names.
    I am trying to create a query to find all orders with details sold by both companies (most orders have all details sold by the same company name).
    This is what I have now:



    Code:
    SELECT DISTINCT tblOrderConf.ConfNum, tblOrderDetails.Seller, Count(tblOrderConf.ConfNum) AS CountOfConfNum
    FROM tblOrderConf INNER JOIN (tblOCLogo INNER JOIN tblOrderDetails ON tblOCLogo.Seller = tblOrderDetails.Seller) ON tblOrderConf.ConfTableID = tblOrderDetails.ConfTableID
    GROUP BY tblOrderConf.ConfNum, tblOrderDetails.Seller
    HAVING (((Count(tblOrderConf.ConfNum))>1))
    ORDER BY tblOrderConf.ConfNum DESC;
    I have it set to only show unique values, but the Count counts each detail record and not the number of records displayed (which would be either 1 or 2).
    Is there a way to have it only count the records displayed? That way if Count > 1 it will only show those orders sold by both companies.

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Wouldn't a duplicates query work for you? Use the wizard and display only the order number, then count number of sellers.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-06-2017, 06:48 AM
  2. Replies: 4
    Last Post: 04-06-2016, 01:29 PM
  3. Count Unique Records in a Report
    By Mohmand in forum Reports
    Replies: 2
    Last Post: 09-10-2014, 10:44 PM
  4. Count unique records - no duplicates
    By Kevo in forum Queries
    Replies: 4
    Last Post: 08-15-2011, 01:19 AM
  5. Count Unique Records
    By PonderingAccess in forum Queries
    Replies: 2
    Last Post: 08-19-2010, 06:54 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