473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Count query counts records not companies

Hi,

I'm new to using queries in Access and am stuck on trying to run a query from a table.

I have thousands of records with fields such as customer name, Company Name, Company Country and Balance. What I want to do is run the query to count the number of Companies within a country. As there are thousands of records one company may be in the table up to a couple hundred times and will be named a few times overs for each country. I use the count feature to count company, group by country and sum balance, as I want to know what the total balance is by country also.

The query is giving me the total number of records by country instead of number of companies per country. The balance sum seems fine.

Can anyone help.

Cheers

Sharkiness
Sep 26 '08 #1
4 1602
FishVal
2,653 Expert 2GB
Hello, Sharkiness.

Try 2-step grouping:
  • First query groups by company and country and sums balance.
  • Second query groups by country, counts company groups from the first one, sums balance subtotals from the first one.

REgards,
Fish
Sep 26 '08 #2
You can also utilize the Distinct statement in SQL.
Sep 26 '08 #3
hjozinovic
167 100+
Maybe the simplest solution would be to add the field Company twice.
Country (Group by)
Company (Group by)
Company (Count)
......
This way you can do it in one simple query :-)
Sep 26 '08 #4
NeoPa
32,556 Expert Mod 16PB
As you have not described the circumstances under which a company may appear multiple times within a country it is not possible to be very specific.

Conceptually though, I'd use a mixture of Fish's and Kristilee's methods. On the inside have a subquery using the DISTINCT predicate of the SELECT clause. As a shell I would count the results.
Sep 26 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Terri | last post by:
I have a form with a multi-select combo. I dynamically build a SELECT statement, open a report, and set the recordsource to my dynamic SELECT statement. I count the records returned in the report...
7
by: Hugo L. | last post by:
Dear I have a table with a Text field named "Attest". In that field I can fill in 4 possibilities: A, B, C or D. In a report based om that table I want to count how many times I filled in...
2
by: pierrelap | last post by:
Hello, I need to code a query that: 1-counts the number of time two companies have been in a deal together 2-in the five years that preceded the deal Lead Participant DealDate AAA BBB ...
2
by: Stephen | last post by:
Hello all Run into a problem with a count query in access. It seems to count either all the results or none depending on criteria even though I have a query that selects the difference in...
1
by: TechnoPup | last post by:
Greetings, I am very new to working with databases, and I am not sure how to go about structuring the query I need. What I have is an Access database with approx. 400,000 records in 5 fields. ...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
2
by: Pete | last post by:
I need to create a single query (Not a SQL query) against a single table that counts the number of records in the table, where the single field "tmp" contains specific string values If the field...
1
by: N06149 | last post by:
I have a report based on a query. I list an Org_Type then Org_Name then the Projects associated with it. Sample of report below: Community Type...
7
by: elainenguyen | last post by:
Hi, I am trying create a query that counts all records which have the field Hypotension=1 (which is Yes), but I only want to count the same customer once. For example: My table has 3 fields:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.