Surely This Is Simple

  • Thread starter Thread starter Paul Smith
  • Start date Start date
P

Paul Smith

I would like to write a query that returns the number of items for items for
each catagory of (1) e.g. for a,b,c,d,e where (2) equals 1.

a 2
b 3
c 2
d 0
e 1

Data

(1) (2)
a 1
a 2
a 1
a 4
b 1
b 1
b 5
b 2
b 1
c 1
c 2
c 3
c 1
d 2
d 2
e 2
e 2
e 1
 
You might try a query whose SQL looks something like this:

SELECT
[Your Table].[Field1],
Count(*) AS [Items]
FROM
[Your Table]
WHERE
[Your Table].[Field2] = 1
GROUP BY
[Your Table].[Field1]

This assumes your table is named "Your Table", the field you identified as
(1) is named "Field1", and the field you identified as (2) is named
"Field2".
 
Back
Top