Queries Questions on Count

W

WMorsberger

I am trying to produce a query that will count items in my table. The report
that I am trying to get at the end shows many different counts for the fields
that I have in the report.

Example: I have a compliments check box and a complaints combo box on the
form. I have many different departments and I need to obtain a count for
each department on the amount of compliments and the amount of complaints
that they received.

What I have so far is this:

SELECT [tbl CM Communications].[Re-Route To], Count([tbl CM
Communications].[Complaint Reason Codes]) AS [CountOfComplaint Reason Codes],
Count([tbl CM Communications].Compliament) AS CountOfCompliament
FROM [tbl CM Communications]
GROUP BY [tbl CM Communications].[Re-Route To]
ORDER BY [tbl CM Communications].[Re-Route To];

When I run this query I am not getting the correct counts. Can someone
please assist me with this?
 
K

KARL DEWEY

It works for me. Exactly what is wrong with your results?
This is the data I used --
Re-Route To Complaint Reason Codes Compliament
1 a
1 a
1 b 1
1 c
2 a
2 1
2 c
3 1
3 2
4
This is the results --
Re-Route To CountOfComplaint Reason Codes CountOfCompliament
1 4 1
2 2 1
3 1 1
4 0 0
 
W

WMorsberger

When I run the query these are the results that I get

Reroute To: complaints compliments
a 1
2
b 2
2
c 1
2

But if I manually go in and look at the data this is what I get

Reroute To: complaints
compliments
a 1
1
b 1
1
c 2



KARL DEWEY said:
It works for me. Exactly what is wrong with your results?
This is the data I used --
Re-Route To Complaint Reason Codes Compliament
1 a
1 a
1 b 1
1 c
2 a
2 1
2 c
3 1
3 2
4
This is the results --
Re-Route To CountOfComplaint Reason Codes CountOfCompliament
1 4 1
2 2 1
3 1 1
4 0 0

WMorsberger said:
I am trying to produce a query that will count items in my table. The report
that I am trying to get at the end shows many different counts for the fields
that I have in the report.

Example: I have a compliments check box and a complaints combo box on the
form. I have many different departments and I need to obtain a count for
each department on the amount of compliments and the amount of complaints
that they received.

What I have so far is this:

SELECT [tbl CM Communications].[Re-Route To], Count([tbl CM
Communications].[Complaint Reason Codes]) AS [CountOfComplaint Reason Codes],
Count([tbl CM Communications].Compliament) AS CountOfCompliament
FROM [tbl CM Communications]
GROUP BY [tbl CM Communications].[Re-Route To]
ORDER BY [tbl CM Communications].[Re-Route To];

When I run this query I am not getting the correct counts. Can someone
please assist me with this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top