|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
MS Access Query
Hi all, This is my first post and I hope someone will be able to assist.
Situation: I'm trying to run an MS Access query on a table that has multiple fields that contain similar data Example: Field1 Field2 Apples Oranges Oranges Apples Apples Apples All I want to do is count how many times "Apples" appear in this table. I can do a simple query to obtain the apple count for any one Field but cannot get a total apple count for the entire table. Any assistance will be greatly appreciated. |
|
#2
|
|||
|
|||
|
To summarize, then... You want something similar to this:
Table: Person Result1 Result2 Result3 Data: Dave 123 456 789 Jody 123 123 456 And you want to count how many times 123 appears in the table? (3 times, in this case) Unfortunately, I don't know how to do this, but I'm sure someone does!!! Is that correct? |
|
#3
|
|||
|
|||
|
Re:
That is correct
Quote:
|
|
#4
|
||||
|
||||
|
Code:
select sum(fieldcount) as totalcount
from (
select count(*) as fieldcount
from fruit
where field1 = 'apples'
union all
select count(*)
from fruit
where field2 = 'apples'
) as dt
|
|
#5
|
|||
|
|||
|
Re:
Quote:
I thought MS Access did not like the SQL select sum(). Maybe I am wrong... I'll give it a try and let you know how I made out. Thanks |
|
#6
|
|||
|
|||
|
Re:
You are da man/woman!!!! Works perfectly.
TYVM!!! |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > MS Access Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|