title: Aggregate function in SQL Server
body: <p>I'm getting really frustrated about SQL Server. I'm just trying to join 3 tables, very simple and easily done in mysql. But in SQL Server it keeps telling me to contain <code>tbl_department.deptname</code> in an aggregate function. But what aggregate function could I possibly use in a simple string? </p>
  
  <pre><code>SELECT      
      COUNT(tblStudent_Department.student_id) AS Expr2, 
      tbl_department.deptname AS Expr1
  FROM          
      tblStudent_Department 
  LEFT OUTER JOIN
      tbl_department ON tblStudent_Department.deptcode = tbl_department.deptcode 
  LEFT OUTER JOIN
      tblStudent ON tblStudent_Department.student_id = tblStudent.studentid
  GROUP BY 
      tblStudent_Department.deptcode
  </code></pre>
  
  <p>Please help.</p>