Solved

Microsoft Access - Count Function

Posted on 2011-03-08
15
579 Views
Last Modified: 2012-06-27
I have an Access Database and is trying to summaries data.  I have a column that lists the branch locations.  Each locations has multiple account numbers.  How do I calcuate for each branch locations the number of account numbers?
0
Comment
Question by:ArisaAnsar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
15 Comments
 
LVL 15

Assisted Solution

by:derekkromm
derekkromm earned 50 total points
ID: 35071883
select branch, count(*) from tablename group by branch
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 50 total points
ID: 35071888
It depends how you are storing the data.
If you mean you have one record per account and that record has the branch on it then you can create a query..

Select Branch, Count(AccountNumber) as NumAccts
from tablename
Group By Branch
0
 

Author Comment

by:ArisaAnsar
ID: 35072443
Thank you both for posting.  I have one record per account and that record has the branch on it.  I am very new to Access so trying to figure out how to implement the instructions you both provided.  I did create a Query, there are other columns but when I try to include the fomula in the Branch Column, I'm getting the following message.

"The expression you entered contains invalid syntax or you need to enclose your text data in quotes."

In the Branch Column, in the criteria section, I have the following:
Branch, Count [Account] as "NumAccts"

Where am I going wrong?
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 15

Expert Comment

by:derekkromm
ID: 35072464
count(account) as "NumAccts"

use (), not [], count is a function
0
 

Author Comment

by:ArisaAnsar
ID: 35072522
I changed as you suggested and is getting the following message.  

"The expression you entered contains invalid syntax. You may have entered an Operand without an operator."

Any other suggestions?  Am I correct in adding this to the Criteria section of the Branch  Column?
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35074079
SELECT BranchAccounts.Branch, Count(BranchAccounts.Account) AS CountOfAccount
FROM BranchAccounts
GROUP BY BranchAccounts.Branch;

BranchAccounts is a Table
Branch is a field for the Branch Location
Account is a feild for the account number.
See attached database for the table and the query.
BranchAccounts.zip
0
 

Author Comment

by:ArisaAnsar
ID: 35074948
Thank you very much for taking the extra step to create a sample database.   I have numerous columns in my query and for some reason, its still not working the same.

When I run the query, it counts each account number once and counts that account only once.  I attached two screenshots below so you can see.

Thanks so very much for your help.
Access-Count-Query-Issue.bmp
Access-Count-Query-Issue1.bmp
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35076530
if you can post a subset of your database I can help. Without having the actuall fields and some data it may be difficult to provide the proper SQL statement.
0
 

Author Comment

by:ArisaAnsar
ID: 35078213
Thanks again.  Sample file attached.
Branch-Tables-Test.zip
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35080383
If you include other fields as  'group by' fields then you cannot get a count just for the branch.  You will get a count for each unique set of all the group fields.

In a totals query you can only include fields which are necessary to get the summaries you want.

0
 

Author Comment

by:ArisaAnsar
ID: 35082192
Thanks!  Is there a way to remove the "group by" from the other columns without impacting the two columns?
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35082297
Yes, you can change GROUP BY to "FIRST" or LAST or MIN or MAX. Then it will give you the FIRST occurance of the data for that field or the LAST occurannce, etc.
0
 
LVL 3

Accepted Solution

by:
AccessYourBiz_Com earned 400 total points
ID: 35085388
I actually created a query to total the accounts by branch and then added that into your query. See attached.
Branch-Tables-by-Scott-Weber.zip
0
 

Author Closing Comment

by:ArisaAnsar
ID: 35087664
Thanks for all of you for responding.   I appreciate your help very much.
The function is finally working correctly.
0
 
LVL 3

Expert Comment

by:AccessYourBiz_Com
ID: 35088015
welcome :-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question