Hi, everyone!
I need help building a query with a column to count the distinct id. What do I mean :
That is my first query (Query1):
That is second query (Query2):
I need to add a column to second query to count id's. So I need to know SumOfinspction_type for each employee and how many sites were inspected.
For example: For employee "Tom" it has 3 inspections for 2 objects..
I need help building a query with a column to count the distinct id. What do I mean :
That is my first query (Query1):
Code:
SELECT tbl_Inspections.inspectionDate, tbl_Inspections.employee,
tbl_Objects.city, Count(tbl_Inspections.inspction_type) AS CountOfinspction_type, tbl_Objects.object_id
FROM tbl_Objects INNER JOIN tbl_Inspections ON tbl_Objects.object_id = tbl_Inspections.object_id
GROUP BY tbl_Inspections.inspectionDate, tbl_Inspections.employee, tbl_Objects.city, tbl_Objects.object_id;
Code:
SELECT
tbl_Employees.employeeName,
Sum(query1.CountOfinspction_type) AS SumOfCountOfinspction_type
FROM
tbl_Employees LEFT JOIN query1 ON tbl_Employees.employeeName = query1.employee
GROUP BY
tbl_Employees.employeeName;
For example: For employee "Tom" it has 3 inspections for 2 objects..