Complicated Query

crozfader

Board Regular
Joined
Mar 23, 2011
Messages
86
Hi everyone I need to create a query that does the following:

I have:

ITEM_NUMBER TRANSACTION_DATES
XYZ 01/02/2011
XYZ 02/02/2011
XYZ 05/02/2011
ZZZ 01/02/2010
ZZZ 01/08/2010
WWW 01/01/2011


etc...

For each product I want to create a query that will return the average time between transactions...

In this case, for item number XYZ there are three transactions. The interval between sales are: 1 day (difference between 02/02/2011 and 01/02/2011) and 3 days (difference between 05/02/2011 and 02/02/2011). The average in this case would be 2 days (3+1/2) for item XYZ.


I also need to calculate the standard deviation of the intervals between sales.

I think that this is done in two steps.
-1) Find a way to add a new column that will contain the difference between a given row and the row preceding it (maybe using some sort of inner join with a sequence?)
- 2) Once that column is created, use a simple group by to calculate avg and stdev

I haven't been able to do this, anyone has ideas?

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
It would be far easier to do this with VBA.

One reason is because Access doesn't actually store records sequentially.

This sort of analysis is much easier to do in Excel.
 
Upvote 0
crozfader, be sure to read the link alan gave you in access world forums, so you understand why cross posting is a poor way to treat those who might be helping you:
http://www.excelguru.ca/node/7
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top