Avatar of mobdog
mobdog
Flag for United States of America asked on

Building Query in Access 2010 to find sequential transactions

     1. Have table of 10,000,000 Customers [ customer name, customer #, transaction date, salesperson ]
      2. Have table of 10,000 customer invoices - relevant fields are: [transaction#, transaction_type, transaction date, customer_name, salesperson ]
      3. Have table of 1,500 customer return invoices - fields[transaction#, transaction_type, transaction date, customer_name, salesperson]
      4. Definition of transaction# - every record has a unique ascending transaction# and every transaction# is created in sequential order and defined by the [transaction_type]
      
      
      
      
      
      I'm looking Query those tables for the following info:
      
      5. Find all transactions where [customer_name ] had a [transaction#] within 10 numbers of another [transaction#] of the same customer.

I am also looking to find sequential transactions with the same customers. i.e. all situations where a customer transaction# is within 1 of another.
Microsoft AccessSQL

Avatar of undefined
Last Comment
dqmq

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dqmq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Dale Fye

dqmq,

Did you mean:

t2.customer# = t2Customer#

OR

T1.customer# = T2.Customer#

Dale Fye

or you could try:

SELECT T1.CustomerID, T1.Transaction#, T2.Transaction#
FROM tblCustomerTransactions as T1
INNER JOIN tblCustomerTransactions as T2
ON T1.CustomerID = T2.CustomerID
AND T1.Transaction# < T2.Transaction#
WHERE (T2.Transaction#-T1.Transaction#) <= [Enter acceptable transaction gap]

dqmq

@fyed>
Of course, you know what I meant :>)  Your correction and politeness are accepted.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy