Results 1 to 2 of 2
  1. #1
    mzaroff is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    1

    Query to see if a client was seen by two providers on the same day.

    Hello,



    I have the following four fields (plus many others) in a table: ClientID ProviderID Dateof ProcID

    I need a query the reveals if a client (ClientID) was seen by two different providers (ProviderID) on the same date (Dateof). It is a large table with more than 300k entries so ordering by client then date and running through it visually is too much. If they were seen by two different providers on the same date then I need to list that information including the procedures that occurred (ProcID) so corrections can be made to a billing code for billing purposes.

    Thanks,
    Mark

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The following should return all client records where any client has more than one record on any date. Unfortunately it won't limit to just the dates with multiple providers.
    SELECT * FROM tablename WHERE ClientID IN (SELECT ClientID FROM tablename GROUP BY ClientID, DateOf WHERE Count("*") > 1);

    Instead, do aggregate query:
    SELECT ClientID, DateOf FROM tablename GROUP BY ClientID, DateOf WHERE Count("*") > 1
    In another query join that query to the original table and link on the ClientID and DateOf fields.

    Another approach (assuming ClientID is number type):
    SELECT * FROM tablename WHERE DCount("*","tablename","ClientID=" & [ClientID] & " AND DateOf=#" & [DateOf] & "#")>1;
    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. Help me figure out a client database? Thanks you.
    By KaelAltreul in forum Database Design
    Replies: 1
    Last Post: 02-28-2013, 10:04 PM
  2. Replies: 1
    Last Post: 07-26-2011, 06:10 AM
  3. Query to match job and client skills?
    By kbp in forum Access
    Replies: 5
    Last Post: 01-27-2011, 05:15 AM
  4. Client Server Database
    By vaikz in forum Database Design
    Replies: 4
    Last Post: 08-02-2010, 04:33 AM
  5. Client History
    By janjan_376 in forum Access
    Replies: 1
    Last Post: 06-23-2009, 02:44 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