R
R
Romario212018-05-15 15:40:56
SQL Server
Romario21, 2018-05-15 15:40:56

MSSQL query error?

I am getting an 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 request:
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 is needed to pull the full name.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2018-05-15
@Romario21

Getting error Column 'SysAdminUnit.Name'

So correct:
No need to save on symbols. No need to use aliases if it makes it difficult to understand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question