I have received help with the query below to show how many employees have taken courses from the total amount of employees but i have hit a problem.
The employees table contains the employeeid, name and location.
An employee can take more than one course which is recorded in the ccompleted table and this is causing the issue.
When the query runs, it is adding the the number of employees records where it finds an employee who has taken a course more than once in the ccompleted table as new employees to the total employees No. table when i run the query.
Is is something to do with the type of join?
SELECT employees, completed, 100.0 * completed / employees AS percent_completed
FROM (SELECT COUNT(*) AS employees, e.Location, COUNT(cc.EmployeeID) AS completed
FROM dbo.Employees AS e LEFT OUTER JOIN
dbo.ccompleted AS cc ON cc.EmployeeID = e.EmployeeID
GROUP BY e.Unit
HAVING (e.Location = N'1')) AS d
The employees table contains the employeeid, name and location.
An employee can take more than one course which is recorded in the ccompleted table and this is causing the issue.
When the query runs, it is adding the the number of employees records where it finds an employee who has taken a course more than once in the ccompleted table as new employees to the total employees No. table when i run the query.
Is is something to do with the type of join?
SELECT employees, completed, 100.0 * completed / employees AS percent_completed
FROM (SELECT COUNT(*) AS employees, e.Location, COUNT(cc.EmployeeID) AS completed
FROM dbo.Employees AS e LEFT OUTER JOIN
dbo.ccompleted AS cc ON cc.EmployeeID = e.EmployeeID
GROUP BY e.Unit
HAVING (e.Location = N'1')) AS d