Solved

Query for matching records across two tables where the time is within +/- 2 minutes

Posted on 2012-03-21
4
272 Views
Last Modified: 2012-03-21
Hello,

I have two tables (TableA and TableB) of transaction logs that have fields of Name and DateTime respectively. Name and DateTime is the composite key. Table B provides a record of Transactions that occur related to TableA. I want to find out if there are any transactions in TableA that do not show-up in TableB.

The problem is that transactions recorded in Table B are often a minute or two (at most) different than what is recorded in Table A (but represent the same transaction). So I would like to create a query that 1) selects all transactions from TableA and TableB that match (where the DateTime field is within +/- 2 minutes of each other) and then 2) return all records from TableA that do not match from that set.

Another point is that some transactions for the Name and DateTime that occur in TableA could be within a minute of one another. So it would seem that some element of differentiating by which occurs first in terms of row (assuming use of rownum or something similar) would need to be addressed as well.

I've attached some sample data in which the goal would be to have the third record in Table A be returned because there is no match in TableB.

Thanks in advance for any assistance with this that can be provided!
matching-by-time-frame-query-dat.xlsx
0
Comment
Question by:nbotts
  • 2
4 Comments
 
LVL 17

Expert Comment

by:xtermie
Comment Utility
Try using a cross tab query or an unmatched records query.
0
 

Author Comment

by:nbotts
Comment Utility
Thanks xtermie, technically the unmatched records query isn't the problem. After all that is provided in the query wizard.

It is more about how to do that given the situation I outlined.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
Comment Utility
Try this...
Open the two tables for viewing, then run Query1
Access-EEQ27643159FindUnmatchedR.mdb
0
 

Author Closing Comment

by:nbotts
Comment Utility
Thank you, that is what I was trying to put together. I guess I had never really experimented with pulling in the query similar to a table. I thought I always had to put together make table queries.

Much appreciated.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now