1. Registered User
Join Date
Oct 2013
Posts
7

I have the following 2 tables which records every buying and selling of Goods as datetime

1- Selling Table
------------------------------------------------------
Date_of_Selling | product id
------------------------------------------------------
15-9-2006 | 1
25-8-2007 | 1
13-8-2009 | 1
16-1-2009 |1
22-1-2010 | 1
..
..

_______________________________________________
and here 2nd Table
----------------------------------------------------
----------------------------------------------------
22-9-2004 | 1
25-16-2006 | 1
1-8-2010 | 1
22-8-2010 | 1
...
..
..

How can I find the average number of weeks between selling and buying ...
using timestampfunction or whatever ?
the result should be like : 5.3 weeks between selling and buying ,
Last edited by michael0; 11-03-13 at 07:44.

2. Registered User
Join Date
Dec 2012
Location
Logan, Utah
Posts
163
Not enough information.

How are the 2 tables related? Something was bought in 2004. How do I know when it was sold?

3. Registered User
Join Date
Oct 2013
Posts
7
there are product_id in each table

4. Registered User
Join Date
Feb 2008
Location
Japan
Posts
3,483
Not enough information.

(What means 25-16-2006 | 1?
_______________________________________________
and here 2nd Table
----------------------------------------------------
----------------------------------------------------
22-9-2004 | 1
25-16-2006 | 1
1-8-2010 | 1
22-8-2010 | 1
...
..
..
(2) How to calculate 5.3 weeks from your sample data?
the result should be like : 5.3 weeks between selling and buying
(3) Always buy and sell one thing at a time?
For example, the following scenario need not to be considered?
Someday bought two goods of a product, then sold one of them later. Finaly sold anoher one.