Solved

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

Posted on 2012-03-21
4
281 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

Technology Partners: 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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

691 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