Ask Your Question

Revision history [back]

I'm basing my reply purely on looking at your code snippet, but I would try this:

SELECT COUNT(Contracts.EmployeeID) as NumEmployees, Contracts.EmployeeID, Employees.FirstName, Employees.LastName, Contracts.Location FROM Contracts LEFT JOIN Employees ON Contracts.EmployeeID=Employees.EmployeeID AND Contracts.Status = Full-time;

Please click the check mark next to the response you believe best answers your question.

REVISION:

@Ratslinger makes some valid points in his response, and negates the need for the COUNT function in my SQL statement (since the rest of my SQL statement deals with the list). However, I believe a JOIN is still needed for the list of employees. I therefore revise my SQL statement as follows:

SELECT Contracts.EmployeeID, Employees.FirstName, Employees.LastName, Contracts.Location FROM Contracts LEFT JOIN Employees ON Contracts.EmployeeID=Employees.EmployeeID AND Contracts.Status = Full-time;

Also, please be aware I am not testing my script prior to responding (as I prefer to do).

^^^^^^^^^^^^^^^^
ORIGINAL RESPONSE
I'm basing my reply purely on looking at your code snippet, but I would try this:

SELECT COUNT(Contracts.EmployeeID) as NumEmployees, Contracts.EmployeeID, Employees.FirstName, Employees.LastName, Contracts.Location FROM Contracts LEFT JOIN Employees ON Contracts.EmployeeID=Employees.EmployeeID AND Contracts.Status = Full-time;

Please click the check mark next to the response you believe best answers your question.