title: Is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
body: <p>I was creating a query, and somehow there seems to be a problem in my query.</p>
  
  <p>Here is my query:</p>
  
  <pre><code>Select
  E.last_name as [Last Name],
  E.first_name as [First Name],
  SUM(CASE WHEN empAttendance.status = 'Absent' THEN 1 ELSE 0 END) as [Absences],
  SUM(CASE WHEN empAttendance.status = 'Late' THEN 1 ELSE 0 END) as [Number of Lates]
  from
  empAttendance
  INNER JOIN employee E ON empAttendance.emp_id = E.emp_id
  WHERE E.company_id = (Select company_id from company Where company_name = @company)
  </code></pre>
  
  <p>Wherein the employee table has the emp_id column which is its PK and also the empAttendance has the emp_id as FK.</p>
  
  <p>employee table has the <code>last_name</code> and the <code>first_name</code> columns.</p>
  
  <p>The error says : <code>Column 'employee.last_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</code></p>
  
  <p>Thanks in advance.</p>