Query to return a value of occurences

  • Thread starter Thread starter Rpettis31
  • Start date Start date
R

Rpettis31

I would like to set up a query to count a value for example Apples in a field.
Basically a query to for customer 1 if he ordered apples more often than
bananas, I would like the query to return customer A with apples. I do not
know the set values for the field as they could vary from a large list. I am
not sure how I would do this.
 
On Fri, 21 Nov 2008 12:26:03 -0800, Rpettis31

Do this in two steps:
step 1: create a query that returns the count for each fruit for each
customer:
select count(fruit) as countoffruit
from myTable
group by customer

Then create a second query, select the first query as the source, and
find the max values:
select customer, max(countoffruit)
from myQuery
group by customer

-Tom.
Microsoft Access MVP
 
Back
Top