The Brown Growler
Registered User.
- Local time
- Today, 10:57
- Joined
- May 24, 2008
- Messages
- 85
Hi,
I would be grateful if anyone could please help me with a query that will provide details of a customers next purchase category based on the category of their previous purchase?
Using the example below:
[Customer] [Site] [OrderDate] [OrderCategory]
Joes Bakery, Rennes, 01/09/2011, C001
Joes Bakery, Rennes, 05/09/2011, C005
Joes Bakery, Rennes, 07/09/2011, C019
Joes Bakery, Rennes, 03/10/2011, C001
Joes Bakery, Rennes, 23/10/2011, C007
Joes Bakery, London, 04/09/2011, C013
Joes Bakery, London, 05/09/2011, C001
Joes Bakery, London, 17/09/2011, C056
Joes Bakery, London, 23/10/2011, C001
Joes Bakery, London, 28/10/2011, C083
I would like to get details of the next customer order when the previous customer order category was C001. The next customer order and previous customer order are defined by the OrderDate field. The result of the query should be as below:
Joes Bakery, Rennes, 05/09/2011, C005
Joes Bakery, Rennes, 23/10/2011, C007
Joes Bakery, London, 17/09/2011, C056
Joes Bakery, London, 28/10/2011, C083
I have though about trying to rank the order dates per Customer and Site then getting the ranking number when the OrderCategory = C001, followed by another query to get the order details for Rank+1. However, if there is another option which is more efficient then I would be grateful for any advice?
Rgds
I would be grateful if anyone could please help me with a query that will provide details of a customers next purchase category based on the category of their previous purchase?
Using the example below:
[Customer] [Site] [OrderDate] [OrderCategory]
Joes Bakery, Rennes, 01/09/2011, C001
Joes Bakery, Rennes, 05/09/2011, C005
Joes Bakery, Rennes, 07/09/2011, C019
Joes Bakery, Rennes, 03/10/2011, C001
Joes Bakery, Rennes, 23/10/2011, C007
Joes Bakery, London, 04/09/2011, C013
Joes Bakery, London, 05/09/2011, C001
Joes Bakery, London, 17/09/2011, C056
Joes Bakery, London, 23/10/2011, C001
Joes Bakery, London, 28/10/2011, C083
I would like to get details of the next customer order when the previous customer order category was C001. The next customer order and previous customer order are defined by the OrderDate field. The result of the query should be as below:
Joes Bakery, Rennes, 05/09/2011, C005
Joes Bakery, Rennes, 23/10/2011, C007
Joes Bakery, London, 17/09/2011, C056
Joes Bakery, London, 28/10/2011, C083
I have though about trying to rank the order dates per Customer and Site then getting the ranking number when the OrderCategory = C001, followed by another query to get the order details for Rank+1. However, if there is another option which is more efficient then I would be grateful for any advice?
Rgds