Counting Entries in Access Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello -

I have a bunch of data that looks like below:

Data
1
2
1
2
2
1

I would like to count the number of 2's and count the number of 1's.

Any help would be super great. Thanks!
 
Have two fields in the query:

1Total: Sum(iif([FieldName] = 1, 1, 0))
2Total: Sum(iif([FieldName] = 2, 1, 0))
 
Another way use a totals query --
SELECT YourTable.FieldName, Count(YourTable.FieldName) AS CountOfFieldName
FROM YourTable
GROUP BY YourTable.FieldName;

--
KARL DEWEY
Build a little - Test a little


Pendragon said:
Have two fields in the query:

1Total: Sum(iif([FieldName] = 1, 1, 0))
2Total: Sum(iif([FieldName] = 2, 1, 0))

DyingIsis said:
Hello -

I have a bunch of data that looks like below:

Data
1
2
1
2
2
1

I would like to count the number of 2's and count the number of 1's.

Any help would be super great. Thanks!
 
I have a bunch of data that looks like below:

Data
1
2
1
2
2
1

I would like to count the number of 2's and count the number of 1's.

Have two fields in the query:

1Total: Sum(iif([FieldName] = 1, 1, 0))
2Total: Sum(iif([FieldName] = 2, 1, 0))

What about when threes are added? What about fours? And fives? etc

Instead, try this:

SELECT FieldName, COUNT(*) AS tally
FROM TableName
GROUP BY FieldName;

Jamie.

--
 
Back
Top