Solved

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

Posted on 2012-03-21
4
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:xtermie
ID: 37750170
Try using a cross tab query or an unmatched records query.
0
 

Author Comment

by:nbotts
ID: 37750221
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
ID: 37750367
Try this...
Open the two tables for viewing, then run Query1
Access-EEQ27643159FindUnmatchedR.mdb
0
 

Author Closing Comment

by:nbotts
ID: 37750691
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

756 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