I am having a brain block in how to get the information out of a query. I have several records for an employee, but I want all the information of one record that has the Max number of days in the SumofHours field. If I group on everything and max out the SumOfHours field, I still get all the records....If I max the SumofHours field and the other fields that are different and group on the employee field, I get messed up data in the other max fields. My code is below..
SELECT qrySumSafety.EmployeeID, qrySumSafety.LastName, qrySumSafety.FirstName, qrySumSafety.MiddleInit, Sum(qrySumSafety.SumOfHours) AS SumOfSumOfHours, Max(qrySumSafety.ForemanLast) AS MaxOfForemanLast, Max(qrySumSafety.ForemanFirst) AS MaxOfForemanFirst, Max(qrySumSafety.ForemanID) AS MaxOfForemanID
FROM qrySumSafety
GROUP BY qrySumSafety.EmployeeID, qrySumSafety.LastName, qrySumSafety.FirstName, qrySumSafety.MiddleInit;
Any help is greatly appreciated
Micki
SELECT qrySumSafety.EmployeeID, qrySumSafety.LastName, qrySumSafety.FirstName, qrySumSafety.MiddleInit, Sum(qrySumSafety.SumOfHours) AS SumOfSumOfHours, Max(qrySumSafety.ForemanLast) AS MaxOfForemanLast, Max(qrySumSafety.ForemanFirst) AS MaxOfForemanFirst, Max(qrySumSafety.ForemanID) AS MaxOfForemanID
FROM qrySumSafety
GROUP BY qrySumSafety.EmployeeID, qrySumSafety.LastName, qrySumSafety.FirstName, qrySumSafety.MiddleInit;
Any help is greatly appreciated
Micki