title: function aggregate in function aggregate
body: <p>I'm working with MySQL and I need to create long command that has to use many aggregate functions. That's my code ...</p>
  
  <pre><code>select count(field) from table group by field order by count(field) desc
  </code></pre>
  
  <p>and I need to SUM or AVG this, I don't know yet but it is irrelevant. When I try to do like this : </p>
  
  <pre><code>select avg(count(field)) from table group by field order by count(field) desc
  </code></pre>
  
  <p>I get error. Is the way to use many of this functions in one query or maybe slice it?</p>
  
  <p>The error is: #1111 - Invalid use of group function</p>