title: CakePHP database queries DISTINCT / GROUP BY error
body: <p>In my CakePHP model I'm trying to get some data from my table.<br>
  I tried using DISTINCT but it seems like using DISTINCT doesn't change the query results.<br>
  I can see many rows that has the same <strong>nick</strong>   </p>
  
  <p>with <strong>'DISTINCT Mytable.nick'</strong></p>
  
  <pre><code>$this-&gt;Mytable-&gt;find('all',
      array(
          'fields'=&gt; array(
              'DISTINCT Mytable.nick',
              'Mytable.age', 'Mytable.location',
          ),
          'conditions' =&gt; array('Mytable.id &gt;=' =&gt; 1, 'Mytable.id &lt;=' =&gt; 100),
          'order' =&gt; array('Mytable.id DESC')
  ));
  </code></pre>
  
  <p>with <strong>'group Mytable.nick'</strong></p>
  
  <pre><code>$this-&gt;Mytable-&gt;find('all',
      array(
          'fields'=&gt; array(
              'Mytable.nick',
              'Mytable.age', 'Mytable.location',
          ),
          'conditions' =&gt; array('Mytable.id &gt;=' =&gt; 1, 'Mytable.id &lt;=' =&gt; 100),
          'group' =&gt; 'Mytable.nick',
          'order' =&gt; array('Mytable.id DESC')
  ));
  </code></pre>
  
  <p>with <strong>'Mytable.nick'</strong></p>
  
  <pre><code>$this-&gt;Mytable-&gt;find('all',
      array(
      'fields'=&gt; array(
              'Mytable.nick',
              'Mytable.age', 'Mytable.location',
      ),
      'conditions' =&gt; array('Mytable.id &gt;=' =&gt; 1, 'Mytable.id &lt;=' =&gt; 100),
      'order' =&gt; array('Mytable.id DESC')
  ));
  </code></pre>
  
  <p>Edit: It seems like even CakePHP 2.1 can't use DISTINCT option. When I tried "GROUP BY" it solved my issue. But as you can see from my query I need to order results with <strong>Mytable.id</strong> descended. When I use GROUP BY, when Mysql finds relevant row, it doesn't take others. For example.</p>
  
  <ul>
  <li>id=1, nick=mike, age=38, location=uk  </li>
  <li>id=2, nick=albert, age=60, location=usa  </li>
  <li>id=3, nick=ash, age=42, location=uk  </li>
  <li>id=4, nick=albert, age=60, location=new_zelland  </li>
  </ul>
  
  <p>When I use <code>group Mytable.nick</code>, I don't see 4th row in my results, I see 2nd row. Because when mysql saw "albert" second time, it doesn't put it into my results. But I need latest "albert" result. Is it not possible?</p>
  
  <p>Edit2: It seems like order by/group by conflict is a common problem. I found some tips in <a href="https://stackoverflow.com/questions/924494/mysql-group-by-ordering">this question</a>. But it gives solution for native Mysql queries. I need a solution for CakePHP type queries.</p>