title: Get error #1111 - Invalid use of group function
body: <p>I have a problem with this Query </p>
  
  <pre><code>SELECT SUM(ROUND( SUM( note=3 ) / count( note=3 ) )) AS AVG, sma_famille.famille
                  FROM sma_notes, sma_famille, sma_agents, sma_service_activite
                  WHERE sma_famille.id_famille &gt;=14
                  AND sma_famille.id_service =9
                  AND sma_notes.id_agent &gt;=7
                  GROUP BY sma_famille.id_famille
  </code></pre>
  
  <p>and i get the error message </p>
  
  <pre><code>#1111 - Invalid use of group function
  </code></pre>
  
  <p>If somebody has experience with this kind of Query.</p>
  
  <p>Here some details of the query:</p>
  
  <p>I i take the query without the first SUM like this (This is the whole query Code)</p>
  
  <pre><code>    SELECT ROUND( SUM( note =3 ) / count( note =3 ) ) AS AVG, sma_famille.famille, sma_notes.id_agent
      FROM sma_notes, sma_famille, sma_agents, sma_service_activite
      WHERE sma_famille.id_famille &gt;=14
      AND sma_famille.id_service =9
      AND sma_notes.id_agent &gt;=7
      AND sma_notes.id_agent = sma_agents.id_agent
      AND sma_service_activite.id_activite = sma_notes.id_activite
      AND sma_service_activite.id_famille = sma_famille.id_famille
      GROUP BY sma_famille.id_famille, sma_notes.id_agent
  </code></pre>
  
  <p>Than i get results like:</p>
  
  <pre><code>    AVG | famille   | id_agent  
      3   |BEL        | 7 
      2   |BEL        | 8 
      1   |BEL        | 9 
      1   |CEL        | 7 
      2   |CEL        | 8 
      1   |CEL        | 9 
  </code></pre>
  
  <p>But with my query who didn't works:</p>
  
  <pre><code>SELECT SUM(ROUND( SUM( note=3 ) / count( note=3 ) )) AS AVG, sma_famille.famille
      FROM sma_notes, sma_famille, sma_agents, sma_service_activite
          WHERE sma_famille.id_famille &gt;=14
          AND sma_famille.id_service =9
          AND sma_notes.id_agent &gt;=7
          AND sma_notes.id_agent = sma_agents.id_agent
          AND sma_service_activite.id_activite = sma_notes.id_activite
          AND sma_service_activite.id_famille = sma_famille.id_famille
          GROUP BY sma_famille.id_famille
  </code></pre>
  
  <p>i want to get this result:</p>
  
  <pre><code>    AVG | famille
      6   |BEL    
      4   |CEL    
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p>Achillix</p>
  
  <p>Cheers</p>