Hello I am trying to execute the following query in MSSQL and for some reason I cant get the DateTime column when I use MAX(MaxNumberLoggedOnAgentsToHalf) in my select statement. it complains :
Column 'Peripheral_Half_Hour.DateTime' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Can anyone assist? Here is my select statement:
SELECT EnterpriseName, MAX(MaxNumberLoggedOnAgentsToHalf) Max_Agents, DateTime
FROM Peripheral_Half_Hour PHH, Peripheral P
WHERE PHH.PeripheralID = P.PeripheralID AND MaxNumberLoggedOnAgentsToHalf > 0
GROUP BY EnterpriseName
Thanks!