title: Subquery in doctrine's createQuery
body: <p>I'm facing a little issue, and I hope someone can help me with it.
  In SQL I have this query which gives me the result I want:</p>
  
  <pre><code>SELECT * FROM price_material AS y 
  JOIN (
     SELECT * FROM price_material_price GROUP BY id DESC
  ) AS x 
  GROUP BY y.price_material_id
  </code></pre>
  
  <p>Now I tried to translate this to my PHP project:</p>
  
  <pre><code>    public function getPriceLines($pricelist = 0, $year = 0, $week = 0)
      {
          if ($year === 0) {
              $year = (int)date('Y');
          }
  
          if ($week === 0) {
              $week = (int)date('W');
          }
  
          $query = $this-&gt;getEntityManager()-&gt;createQuery('
            SELECT pgp FROM ACME\Bundle\PricelistBundle\Entity\PricelistMaterialPrice pgp
            INNER JOIN (SELECT * FROM ACME\Bundle\PricelistBundle\Entity\PricelistMaterial ORDER BY id DESC)
            WHERE pr.pricelist = :pricelist AND pgp.year &lt;= :year
            AND pgp.week &lt;= :week
            GROUP BY pgp.pricelistmaterial
            ORDER BY pgp.year DESC, pgp.week DESC, pgp.id DESC
          ')-&gt;setParameters(array('pricelist' =&gt; $pricelist, 'week' =&gt; $week, 'year' =&gt; $year));
  
          $result = $query-&gt;getResult();
  
          return $result;
      }
  </code></pre>
  
  <p>But a subquery in a join isn't possible, as what I think, because this gives me the error:</p>
  
  <pre><code>[Semantical Error] line 0, col 119 near '"(SELECT * FROM': Error: Class '"' is not defined.
  </code></pre>
  
  <p>Can someone point me in the right direction?</p>