Graham T
Registered User.
- Local time
- Today, 22:29
- Joined
- Mar 14, 2001
- Messages
- 300
Whilst looking for a solution to a problem today, I came across a couple of topics by Pat H and Jon K and managed to cobble together the following:
Now this appear to do what is required.
It returns the top 2 most recent orders for each UserID. But how it does this is the part I don't understand.
If anyone can throw some light on it I would apprieciate the response.
TIA
Graham
Code:
Select OrderNum, OrderDate
FROM Order_Lines AS ol
WHERE (SELECT COUNT(*) FROM Order_Lines
WHERE UserID = ol.UserID AND OrderDate > ol.OrderDate) + 1 < = 2
It returns the top 2 most recent orders for each UserID. But how it does this is the part I don't understand.
If anyone can throw some light on it I would apprieciate the response.
TIA
Graham