MSSQL error in the query?

I get this error:
Msg 8120, Level 16, State 1, Line 2
Column 'SysAdminUnit.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.


Here is the query:
SELECT COUNT(l.Id) AS COUNT, l.OwnerId, u.Name 
FROM Lead l 
LEFT OUTER JOIN SysAdminUnit u ON l.OwnerId = u.Id 
WHERE (QualifyStatusId = '6f4ac06a-af62-495d-b13a-e68dc6b9c53b' 
 OR QualifyStatusId='db93b4dc-45b6-40e4-81f4-d14d43655d0e') 
 AND CreatedOn LIKE '2018-05-15%' 
GROUP BY OwnerId

The task is to count the number of entries made by the user for the current day. JOIN need to pull the name.
June 5th 19 at 22:01
1 answer
June 5th 19 at 22:03
Solution
Get the error Column 'SysAdminUnit.Name'

So correct:
GROUP BY l.OwnerId, u.Name

Don't skimp on the characters. No need to use aliases, if it is difficult to understand.
Thank you very much) - wayne_Goyette commented on June 5th 19 at 22:06

Find more questions by tags SQL Server