Need to see zeroe's in the Query result

coach.32

Registered User.
Local time
Today, 21:36
Joined
Aug 14, 2011
Messages
28
I have created a Query (with Totals) that counts various criteria. I need the query result to show zeros, so that all figures can be transposed correctly to a report. This report needs to go out daily and the recipents need to see where the zero's are. I have used the following formula, but alas... no zero's. Any assistance would be gratefully accepted.
SELECT NZ(Count([Compromised TFN - master].[Team_Id]),0) AS CountOfTeam_Id, [Compromised TFN - master].Acty_Priority, [Compromised TFN - master].Acty_Cmplxty, [Compromised TFN - master].Team_Id, [Compromised TFN - master].Acty_Cntct_Typ_Nm, [Compromised TFN - master].Intractn_Sts
FROM [Compromised TFN - master]
GROUP BY [Compromised TFN - master].Acty_Priority, [Compromised TFN - master].Acty_Cmplxty, [Compromised TFN - master].Team_Id, [Compromised TFN - master].Acty_Cntct_Typ_Nm, [Compromised TFN - master].Intractn_Sts
HAVING ((([Compromised TFN - master].Acty_Priority)="3-Medium") AND (([Compromised TFN - master].Acty_Cmplxty)="Low") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="3-Medium") AND (([Compromised TFN - master].Acty_Cmplxty)="Medium") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="3-Medium") AND (([Compromised TFN - master].Acty_Cmplxty)="High") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="4-Low") AND (([Compromised TFN - master].Acty_Cmplxty)="Low") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="4-Low") AND (([Compromised TFN - master].Acty_Cmplxty)="Medium") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="4-Low") AND (([Compromised TFN - master].Acty_Cmplxty)="High") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="2-High") AND (([Compromised TFN - master].Acty_Cmplxty)="Low") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="2-High") AND (([Compromised TFN - master].Acty_Cmplxty)="Medium") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval")) OR ((([Compromised TFN - master].Acty_Priority)="2-High") AND (([Compromised TFN - master].Acty_Cmplxty)="High") AND (([Compromised TFN - master].Team_Id)=1743) AND (([Compromised TFN - master].Acty_Cntct_Typ_Nm)="REG Compromised TFN") AND (([Compromised TFN - master].Intractn_Sts)="For Approval"));
 
each record counts as one. but if you sum certain columns, which you add, which contains the value 1 or 0 as needed, you can circumvent this problem.

you can put 1 in a column if it meets your requirements or 0 if it doesn't.
this can be done using an iif statement. but when i look at your query it will be quite an iif statement. good luck with that.

second, the above select statement contains a logical fault. it is not an error in any way.

the nz function in your select statement doesn't do anything because Count doesn't return null. so it is never converted to 0.

SELECT NZ(Count([Compromised TFN - master].[Team_Id]),0) AS CountOfTeam_Id

HTH:D
 

Users who are viewing this thread

Back
Top Bottom