title: SQL subselect group function not allowed
body: <p>I'm facing a problem with an SQL subquery: I need to write a query which returns the courses where the number of subscriptions (count(employeeNumber)) is greater than the maximum allowed number of subscriptions (Maximum).</p>
  
  <p>In my original query I'm getting following error:
  <b>Group function is not allowed here</b>.</p>
  
  <p>The query:</p>
  
  <pre><code>SELECT c.CourseName 
  FROM courses c 
  INNER JOIN subscriptions s ON s.courseCode = c.CourseCode 
  INNER JOIN plannedCourses p ON p.CourseCode = s.CourseCode
  WHERE COUNT(s.EmployeeNumber) &gt; (SELECT maximum 
                                   FROM plannedCourses 
                                   WHERE s.CourseCode = p.CourseCode);
  </code></pre>
  
  <p>The table layout:</p>
  
  <p><img src="https://i.stack.imgur.com/xOHyj.png" alt="Table layout"></p>
  
  <p><b>How can i achieve the desire result?</p>
  
  <p>Thanks in advance!!</b></p>