title: Help needed converting MySQL query to Doctrine Query
body: <p>I'm trying to convert the following MySQL query which give me all clients who have not had an appointment for six months or more into a DQL query.</p>
  
  <pre><code>mysql&gt; select appt.lastDate, clients.firstname, clients.lastname
  -&gt; from (select max(gapmtDate) as lastDate,gapmtClient from groomappointments group by gapmtClient) as appt ,clients
  -&gt; where date_sub(CURDATE(), INTERVAL 6 MONTH)&gt;lastDate
  -&gt; AND clients.clientid = appt.gapmtClient;
  </code></pre>
  
  <p>I've tried to match this with the following but I receive an error stating that there is an unknown column g__0 in the where clause. Can anyone point out where I'm going wrong</p>
  
  <pre><code>public function noappointmentsforsixmonthsAction()
  {
  
  
  
    $sixmonths=date('y-m-d',strtotime("-6 months"));
  
    $q=Doctrine_Query::create()
    -&gt;select('MAX(g.gapmtDate) AS lastDate, c.firstname, c.lastname,g.gapmtClient')
   -&gt;from('PetManager_Model_Groomappointments g')
   -&gt;leftJoin('g.PetManager_Model_Clients c')
   -&gt;where('lastDate &lt;?',$sixmonths)
   -&gt;groupBy('g.gapmtClient');
  
   .......
  
  }
  </code></pre>
  
  <p>EDIT</p>
  
  <p>Ok it seems the Doctrine site has been down all day I've tried editing the query to that below but it still won't work. Can any one give me the correct syntax.</p>
  
  <pre><code>$q=Doctrine_Query::create()
  -&gt;select('a.lastDate, c.firstname, c.lastname')
  -&gt;addSelect('(SELECT MAX(gapmtDate) AS lastDate, gapmtClient FROM PetManager_Model_Groomappointments GROUP BY gapmtClient) as a')
  -&gt;from('PetManager_Model_Groomappointments a')
   -&gt;leftJoin('a.PetManager_Model_Clients c')   
   -&gt;where('a.gapmtClient=c.clientID')
   -&gt;andWhere('lastDate &gt;?',$sixmonths);
  </code></pre>