I wish my query to look at one column of data in a table and ask user for parameter to search for & return a total on ie. ourrances of SMITH in surname, instead of writing seperate queries for each parameter.
To follow up on what Leslie provided. If you wanted to have the flexibility of providing a count for all the names based on matching only part of the name you could do what follows. The LIKE statement allows a pattern or part of a pattern to be used to give you results.
SELECT LastName, Count(LastName) AS CountOfLastName
FROM TableName
GROUP BY LastName
HAVING (((LastName) Like [Enter Last Name] & "*");
One finally thing to make you aware of. If nothing is entered for the SQL statement that uses the LIKE option
you will get a list of unique names and counts of those names for all the entries.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.