title: Zend\Db: Select from subquery
body: <p>I'm porting an application from ZF1 to ZF2 and as part of that I have to rewrite our database mappers.</p>
  
  <p>I'm struggling with this SQL statement:</p>
  
  <pre><code>SELECT full_name, GROUP_CONCAT(value)
  FROM (
     SELECT full_name, value
     FROM my_table
     ORDER BY id DESC
     ) as subtable
  GROUP BY full_name
  ORDER BY full_name DESC;
  </code></pre>
  
  <p>The underlying problem I'm trying to solve is that I need to order the results of the sub query before running <code>GROUP_CONCAT</code> and I need it to work for both MySQL and Sqlite. In MySQL I could simply specify the order within the <code>GROUP_CONCAT</code> function, but this is not possible with Sqlite so I need the sub query for it to be compatible with both MySQL and Sqlite.</p>
  
  <p>In ZF1 I could do:</p>
  
  <pre><code>$fromSql = $db-&gt;select()
                -&gt;from('my_table', array('full_name', 'value'))
                -&gt;order('id DESC');
  
  $sql = $db-&gt;select()
            -&gt;from(array(
                  'subtable' =&gt; new Zend_Db_Expr('(' . $fromSql . ')')
              ), array(
                  'full_name' =&gt; 'full_name',
                  'value' =&gt; new Zend_Db_Expr('GROUP_CONCAT(subtable.value)'),
              )
            )
            -&gt;group('full_name')
            -&gt;order('full_name DESC');
  </code></pre>
  
  <p>However, using a sub query in the from clause doesn't seem possible with ZF2. Is there some work around for this?</p>