L
Liliane
Hi,
I'm writing a query. It was fine with grouping by Programs, but now I need
to add another category group -- Audit_Group, I got results duplicated.
The SQL is:
SELECT tbl_Audits.Audit_Group, tbl_Programs.Program_ID,
tbl_Programs.Program_Report_Label,
(IIf(IsNull([qry_Monthly_Report_Sub1_Q1]![Items_Sampled]),0,[qry_Monthly_Report_Sub1_Q1]![Items_Sampled]))
AS Items_Sampled, qry_Monthly_Report_Sub1_Q1.Items_Re_Opened,
Count(qry_Reopened_Items.Audit_No) AS CountOfAudit_No
FROM (((tbl_Programs INNER JOIN qry_Monthly_Report_Sub1_Q1 ON
tbl_Programs.Program_ID = qry_Monthly_Report_Sub1_Q1.Program_ID) INNER JOIN
tbl_Projects ON tbl_Programs.Program_ID = tbl_Projects.Program_ID) INNER JOIN
tbl_Work_Packages ON tbl_Projects.Project_ID = tbl_Work_Packages.Project_ID)
INNER JOIN (tbl_Audits LEFT JOIN qry_Reopened_Items ON tbl_Audits.Audit_No =
qry_Reopened_Items.Audit_No) ON tbl_Work_Packages.Work_Package_ID =
tbl_Audits.Work_Package_ID
GROUP BY tbl_Audits.Audit_Group, tbl_Programs.Program_ID,
tbl_Programs.Program_Report_Label,
(IIf(IsNull([qry_Monthly_Report_Sub1_Q1]![Items_Sampled]),0,[qry_Monthly_Report_Sub1_Q1]![Items_Sampled])),
qry_Monthly_Report_Sub1_Q1.Items_Re_Opened, tbl_Audits.Carried_Out
HAVING (((tbl_Programs.Program_ID)<>"08") AND ((tbl_Audits.Carried_Out)=Yes))
ORDER BY tbl_Audits.Audit_Group DESC , tbl_Programs.Program_ID;
Currently, the results I get are (The last 3 lines should be 0):
Audit_Group Program_ID Items_Sampled Items_Re_Opened
Strategic 10 9 3
Performance 01 444 33
Performance 02 771 105
Performance 04 87 5
Performance 07 0 0
Performance 10 (9) (3)
Operational 10 (9) (3)
Certification 10 (9) (3)
Please help me!~
Many thanks!!!!
I'm writing a query. It was fine with grouping by Programs, but now I need
to add another category group -- Audit_Group, I got results duplicated.
The SQL is:
SELECT tbl_Audits.Audit_Group, tbl_Programs.Program_ID,
tbl_Programs.Program_Report_Label,
(IIf(IsNull([qry_Monthly_Report_Sub1_Q1]![Items_Sampled]),0,[qry_Monthly_Report_Sub1_Q1]![Items_Sampled]))
AS Items_Sampled, qry_Monthly_Report_Sub1_Q1.Items_Re_Opened,
Count(qry_Reopened_Items.Audit_No) AS CountOfAudit_No
FROM (((tbl_Programs INNER JOIN qry_Monthly_Report_Sub1_Q1 ON
tbl_Programs.Program_ID = qry_Monthly_Report_Sub1_Q1.Program_ID) INNER JOIN
tbl_Projects ON tbl_Programs.Program_ID = tbl_Projects.Program_ID) INNER JOIN
tbl_Work_Packages ON tbl_Projects.Project_ID = tbl_Work_Packages.Project_ID)
INNER JOIN (tbl_Audits LEFT JOIN qry_Reopened_Items ON tbl_Audits.Audit_No =
qry_Reopened_Items.Audit_No) ON tbl_Work_Packages.Work_Package_ID =
tbl_Audits.Work_Package_ID
GROUP BY tbl_Audits.Audit_Group, tbl_Programs.Program_ID,
tbl_Programs.Program_Report_Label,
(IIf(IsNull([qry_Monthly_Report_Sub1_Q1]![Items_Sampled]),0,[qry_Monthly_Report_Sub1_Q1]![Items_Sampled])),
qry_Monthly_Report_Sub1_Q1.Items_Re_Opened, tbl_Audits.Carried_Out
HAVING (((tbl_Programs.Program_ID)<>"08") AND ((tbl_Audits.Carried_Out)=Yes))
ORDER BY tbl_Audits.Audit_Group DESC , tbl_Programs.Program_ID;
Currently, the results I get are (The last 3 lines should be 0):
Audit_Group Program_ID Items_Sampled Items_Re_Opened
Strategic 10 9 3
Performance 01 444 33
Performance 02 771 105
Performance 04 87 5
Performance 07 0 0
Performance 10 (9) (3)
Operational 10 (9) (3)
Certification 10 (9) (3)
Please help me!~
Many thanks!!!!