- Local time
- Today, 07:59
- Joined
- Sep 12, 2006
- Messages
- 16,118
I'm struggling with this one.
first, I do a total query to retreive the frequency of a certain attribute
eg This produces
Customer Depot Order
CustA North 12 orders
CustA South 8 orders
CustA East 10 orders etc
CustB North 9
CustB West 11
CustB East 10
So now I want to retrieve for each customer, the Depot with the highest order count
ie
CustA North (12)
CustB West (11)
I can't find the right structure for the second query to generate the answer, because as soon as I do a group by, I get all Depots again! Or can I do the whole thing with one query.
If there are two similar max counts, ideally, I want to return either one. I suppose I could do a dlookup on the max count to retrieve the associated depot, but this seems sloppy.
first, I do a total query to retreive the frequency of a certain attribute
eg This produces
Customer Depot Order
CustA North 12 orders
CustA South 8 orders
CustA East 10 orders etc
CustB North 9
CustB West 11
CustB East 10
So now I want to retrieve for each customer, the Depot with the highest order count
ie
CustA North (12)
CustB West (11)
I can't find the right structure for the second query to generate the answer, because as soon as I do a group by, I get all Depots again! Or can I do the whole thing with one query.
If there are two similar max counts, ideally, I want to return either one. I suppose I could do a dlookup on the max count to retrieve the associated depot, but this seems sloppy.