title: Hibernate multiple group by month
body: <p>I want to join 2 <code>group by</code> queries. The mysql query looks like this:</p>
  <pre><code>SELECT d.m,d.fn/(d.fn+d2.tp)*100 FROM 
  (
      SELECT MONTH(created_at) AS m, COUNT(*) AS fn 
      FROM documents 
      WHERE 
      document_state = &quot;APPROVED&quot; 
      GROUP BY m
  ) d 
  JOIN 
  (
      SELECT MONTH(created_at) AS m, COUNT(*) AS tp 
      FROM documents 
      WHERE 
      document_state = &quot;AUTHENTIC&quot; 
      GROUP BY m
  ) d2 
  ON d.m = d2.m
  </code></pre>
  <p>I was unable to convert to HQL, because hibernate doesn't support subquery in the <code>from</code>.</p>