title: Select from Select in QueryDSL
body: <p>I wonder if there is a way to phrase something like </p>
  
  <pre><code>SELECT `sum(&lt;field&gt;)` FROM (SELECT field from ... WHERE ...)
  </code></pre>
  
  <p>in QueryDSL(Version 4.x).</p>
  
  <p>Let's say I have an <em>Article</em> "green Balloon" in all my <em>Stores</em> and I need to know how many "green Balloon" I have in total (I know it's a stupid example but it will do ;)).</p>
  
  <p>The SQL could look like:</p>
  
  <pre><code>SELECT count(a.id) 
      FROM (
          SELECT art.id 
          FROM article art
          LEFT JOIN store s ON (art.storeId = s.id)
          WHERE art.name = 'green Balloon'
          GROUP BY s.id
      ) a;
  </code></pre>
  
  <p>How can I translate said SQL to QueryDSL?</p>
  
  <p>Edit: As it was subject to confusion: <strong>Yes, the example is stupid. No I do not want to 'optimize' the SQL</strong>. All I need is some QueryDSL-Code generating the exact same (stupid) SQL. Or any other QueryDSL-Code generation any sort of <code>SELECT ... FROM (SELECT ...)</code> for that matter. If that is even possible.</p>
  
  <p><a href="https://stackoverflow.com/questions/25690447/how-can-i-count-the-number-of-result-groups-in-querydsl?rq=1" title="This old post">There is a two year old post</a> handling this topic, but apparently it was not possible then. Maybe it is now?</p>