>I tried this SQL in a VB app and I get an expected 1 error. Where is the error in this SQL. (What I want to do is only return employees if they have reportrequests.)
>
>SELECT Employees.ID, Employees.FirstName,
> Employees.LastName, Employees.Department,
> COUNT(ReportRequests.ID) AS Ctr
>FROM Employees, ReportRequests
>WHERE Employees.ID = ReportRequests.EmpID AND (Ctr > 0)
>GROUP BY Employees.ID, Employees.FirstName,
> Employees.LastName, Employees.Department
Change the Ctr part of the WHERE clause to a HAVING clause using the actual COUNT() statement:
SELECT Employees.ID, Employees.FirstName,
Employees.LastName, Employees.Department,
COUNT(ReportRequests.ID) AS Ctr
FROM Employees, ReportRequests
WHERE Employees.ID = ReportRequests.EmpID
HAVING Count(ReportRequests.ID) > 0
GROUP BY Employees.ID, Employees.FirstName,
Employees.LastName, Employees.Department
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao