Count not right

Q

QB

I have a table that I am using to generate a pie chart from by counting the
number of instance of in a column. However, to always display all the
choices, even when not present I am performing a join with a table which list
the 3 possible choices. That said, when I perform a count it does not return
the correct value. Below is my sql

SELECT [tbl_rpt_A].Type, [tbl_rpt_A].[Respect de estime des heures atelier],
Nz(Count([Resp]),0) AS CountResp
FROM [tbl_rpt_A] LEFT JOIN [qry_rpt_A] ON ([tbl_rpt_A].[Respect de estime
des heures atelier] = [qry_rpt_A].Resp) AND ([tbl_rpt_A].Type =
[qry_rpt_A].Type)
GROUP BY [tbl_rpt_A].Type, [tbl_rpt_A].[Respect de estime des heures atelier];

I get the proper, complete list of choices, but the count is incorrect?

If you might point out where I have gone wrong, or a better way to do this,
I would be oh so grateful!

QB
 
M

Marshall Barton

QB said:
I have a table that I am using to generate a pie chart from by counting the
number of instance of in a column. However, to always display all the
choices, even when not present I am performing a join with a table which list
the 3 possible choices. That said, when I perform a count it does not return
the correct value. Below is my sql

SELECT [tbl_rpt_A].Type, [tbl_rpt_A].[Respect de estime des heures atelier],
Nz(Count([Resp]),0) AS CountResp
FROM [tbl_rpt_A] LEFT JOIN [qry_rpt_A] ON ([tbl_rpt_A].[Respect de estime
des heures atelier] = [qry_rpt_A].Resp) AND ([tbl_rpt_A].Type =
[qry_rpt_A].Type)
GROUP BY [tbl_rpt_A].Type, [tbl_rpt_A].[Respect de estime des heures atelier];

I get the proper, complete list of choices, but the count is incorrect?


How is the count incorrect?

One thing to be aware of is that Count([Resp]) counts
records that are not null in the Resp field. To count all
records, use Count(*)
 

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