Query showing how many times someone's name has appeared

  • Thread starter Thread starter Clay Forbes
  • Start date Start date
C

Clay Forbes

I need the code for a query that tells how many times each person has appeared.
Example- Jim has appeared 7 times in this table.
How would i do that?
 
Hi,
Something like this:

SELECT Count(tblNames.fNames) AS CountOfNames, tblNames.fNames
FROM tblNames
GROUP BY tblNames.fNames;

substitute your table and field names
 
SELECT PersonName, Count([PersonName]) As PersonAppearances
FROM [YourTable]
GROUP BY PersonName
 
That doesn't work when i put it in query criteria. What i need to have
it count how many times each person's name shows up and put that in a
field called "appear" Does the code go under criter criteria?

Van T. Dinh said:
SELECT PersonName, Count([PersonName]) As PersonAppearances
FROM [YourTable]
GROUP BY PersonName

--
HTH
Van T. Dinh
MVP (Access)


Clay Forbes said:
I need the code for a query that tells how many times each person has appeared.
Example- Jim has appeared 7 times in this table.
How would i do that?
 
No. The SQL Strings Dan & I posted are the whole Queries. They are not the
criteria.

In the DesignView of your Query, switch to SQLView and paste the String Dan
or I posted (with suitable modification for your Table / Field names) and
then you can run it or switch back to DesignView.
 
When i use the code you gave me it just gives me a total number of all
the people that appear. (i.e. the names that are in the table are
"test1" "test1" and "test". When i run that query it gives me under
the appear colomn the number 3. What i need is under the appear colomn
next to test1 it says 2 and under test2 it says one.)
How do i do that?

Van T. Dinh said:
SELECT PersonName, Count([PersonName]) As PersonAppearances
FROM [YourTable]
GROUP BY PersonName

--
HTH
Van T. Dinh
MVP (Access)


Clay Forbes said:
I need the code for a query that tells how many times each person has appeared.
Example- Jim has appeared 7 times in this table.
How would i do that?
 
Post relevant details of your Table (i.e. Fields, PK) and the SQL String of
your attempt(s) rather than we try to guess your Table details.
 
Ok, It works now. I re-read whwat i copied and the group by statement
wasnt there. Thats why it didn't work for me.
Thanks for all the help.

When i use the code you gave me it just gives me a total number of all
the people that appear. (i.e. the names that are in the table are
"test1" "test1" and "test". When i run that query it gives me under
the appear colomn the number 3. What i need is under the appear colomn
next to test1 it says 2 and under test2 it says one.)
How do i do that?

Van T. Dinh said:
SELECT PersonName, Count([PersonName]) As PersonAppearances
FROM [YourTable]
GROUP BY PersonName

--
HTH
Van T. Dinh
MVP (Access)


Clay Forbes said:
I need the code for a query that tells how many times each person has appeared.
Example- Jim has appeared 7 times in this table.
How would i do that?
 
Back
Top