count

  • Thread starter enrico via AccessMonster.com
  • Start date
E

enrico via AccessMonster.com

if i have a table with fields lastname and address, how do i get the total
count of lastnames in a specific address?
e.g.
# of people living in "Manila"
 
S

Stefan_889_12

hi,

paste this code into sql design mode of your new query.

SELECT MyTable.address, Count(MyTable.address) AS CountOfaddress
FROM MyTable
GROUP BY MyTable.address;

Stefan.
 
K

karl dewey

Try this --
SELECT Count([lastname]) AS Name_Count
FROM YourTable
WHERE [address] Like "*" & [Enter city] & "*";
 
E

enrico via AccessMonster.com

i tried this as my code:

SELECT Count(tblGenInfo.Lastname) AS NumberOfNames
FROM tblGenInfo
WHERE (((tblGenInfo.Hospital)="Abella Midway Hospital"))
GROUP BY [tblGenInfo.Hospital], tblGenInfo.DateofSurvey
HAVING (((tblGenInfo.DateofSurvey) Between #2/1/2008# And #1/2/2010#))
ORDER BY [tblGenInfo.Hospital];

my problem is the result would return the count individually, there are four
results and the query would return for columns of 1 count. why doesn't it
return only 1 column with 4 counts?
 
K

karl dewey

why doesn't it return only 1 column with 4 counts?
I do not understand your question but try this.

SELECT Count(tblGenInfo.Lastname) AS NumberOfNames
FROM tblGenInfo
WHERE (((tblGenInfo.Hospital)="Abella Midway Hospital")) AND
(((tblGenInfo.DateofSurvey) Between #2/1/2008# And #1/2/2010#));
 
Top