A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculating transactions by time



 
 
Thread Tools Display Modes
  #1  
Old April 28th, 2010, 03:58 PM posted to microsoft.public.access
sabunim
external usenet poster
 
Posts: 5
Default Calculating transactions by time

Here's my problem, I have customer transaction data that shows deposits and
withdrawals for a month. My data includes the customer ID, type of trans,
date of trans, time of trans and amount. I am trying to come up with a way
to count the number of times a customer makes a deposit then immediately
makes a withdrawal. Obviously this will occur on the same date and within a
minute or less of the deposit. I can pull a query showing the two relevent
transactions together in a table but how do I count the number of
occurrences. Any help is appreciated. Thanks!
  #2  
Old April 28th, 2010, 05:14 PM posted to microsoft.public.access
Dorian
external usenet poster
 
Posts: 542
Default Calculating transactions by time

SELECT COUNT()
Look it up in Help.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"sabunim" wrote:

Here's my problem, I have customer transaction data that shows deposits and
withdrawals for a month. My data includes the customer ID, type of trans,
date of trans, time of trans and amount. I am trying to come up with a way
to count the number of times a customer makes a deposit then immediately
makes a withdrawal. Obviously this will occur on the same date and within a
minute or less of the deposit. I can pull a query showing the two relevent
transactions together in a table but how do I count the number of
occurrences. Any help is appreciated. Thanks!

  #3  
Old April 28th, 2010, 05:16 PM posted to microsoft.public.access
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Calculating transactions by time

Have you checked to see if the Totals query can do the calculating you need?
Try the Count aggregation...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"sabunim" wrote in message
...
Here's my problem, I have customer transaction data that shows deposits
and
withdrawals for a month. My data includes the customer ID, type of trans,
date of trans, time of trans and amount. I am trying to come up with a
way
to count the number of times a customer makes a deposit then immediately
makes a withdrawal. Obviously this will occur on the same date and within
a
minute or less of the deposit. I can pull a query showing the two
relevent
transactions together in a table but how do I count the number of
occurrences. Any help is appreciated. Thanks!



  #4  
Old April 28th, 2010, 06:13 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Calculating transactions by time

You'll need to join two instances of the table (CurrentAccounts below) on
the account holder being the same (same AccountNumber), the transaction's not
being the same transaction (different TransactionID), one being a deposit
(Credit 0), the other a withdrawal (Debit 0) and the transaction times
being close (5 minutes or less in the example below)

SELECT A1.AccountNumber, COUNT(*) AS ImmediateWithdrawals
FROM CurrentAccounts As A1, CurrentAccounts AS A2
WHERE A1.AccountNumber = A2.Accountnumber
AND A1.Credit 0 AND A2.Debit 0
AND A1.TransactionID A2.TransactionID
AND DATEDIFF("n",A1.TransactionDate+A1.TransactionTime ,
A2.TransactionDate+A2.TransactionTime) BETWEEN 0 AND 5
GROUP BY A1.AccountNumber;

Bear in mind that if one deposit and two withdrawals are made within a 5
minute period this would count as two occurrences, not one.

Ken Sheridan
Stafford, England

sabunim wrote:
Here's my problem, I have customer transaction data that shows deposits and
withdrawals for a month. My data includes the customer ID, type of trans,
date of trans, time of trans and amount. I am trying to come up with a way
to count the number of times a customer makes a deposit then immediately
makes a withdrawal. Obviously this will occur on the same date and within a
minute or less of the deposit. I can pull a query showing the two relevent
transactions together in a table but how do I count the number of
occurrences. Any help is appreciated. Thanks!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201004/1

  #5  
Old April 29th, 2010, 09:08 PM posted to microsoft.public.access
sabunim
external usenet poster
 
Posts: 5
Default Calculating transactions by time

Excellent! I followed your thought process, tweaked it a bit and got it work
for me. Thank you!

"KenSheridan via AccessMonster.com" wrote:

You'll need to join two instances of the table (CurrentAccounts below) on
the account holder being the same (same AccountNumber), the transaction's not
being the same transaction (different TransactionID), one being a deposit
(Credit 0), the other a withdrawal (Debit 0) and the transaction times
being close (5 minutes or less in the example below)

SELECT A1.AccountNumber, COUNT(*) AS ImmediateWithdrawals
FROM CurrentAccounts As A1, CurrentAccounts AS A2
WHERE A1.AccountNumber = A2.Accountnumber
AND A1.Credit 0 AND A2.Debit 0
AND A1.TransactionID A2.TransactionID
AND DATEDIFF("n",A1.TransactionDate+A1.TransactionTime ,
A2.TransactionDate+A2.TransactionTime) BETWEEN 0 AND 5
GROUP BY A1.AccountNumber;

Bear in mind that if one deposit and two withdrawals are made within a 5
minute period this would count as two occurrences, not one.

Ken Sheridan
Stafford, England

sabunim wrote:
Here's my problem, I have customer transaction data that shows deposits and
withdrawals for a month. My data includes the customer ID, type of trans,
date of trans, time of trans and amount. I am trying to come up with a way
to count the number of times a customer makes a deposit then immediately
makes a withdrawal. Obviously this will occur on the same date and within a
minute or less of the deposit. I can pull a query showing the two relevent
transactions together in a table but how do I count the number of
occurrences. Any help is appreciated. Thanks!


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201004/1

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.