title: Cakephp calculating average problem
body: <p>I have this query:</p>
  
  <pre><code>   $this-&gt;set('grades', $this-&gt;Grade-&gt;Query("
  SELECT AVG(grade), 
  sections.section_name 
  
  FROM grades, 
  sections 
  
  WHERE sections.id = grades.section_id 
  
  AND grades.user_id =".$id." 
  
  GROUP BY grades.section_id"));
  </code></pre>
  
  <p>And I use this to output the data:</p>
  
  <pre><code>&lt;?php foreach($grades as $grade): ?&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $grade['Grade']['AVG(grade)']; ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;?php endforeach;?&gt;
  </code></pre>
  
  <p>But it gives me a "warning index Grade not found". I suspect it got to do with the <code>['AVG(grade)']</code> because when I remove the AVG(grade) it outputs normal (without avg values obviously)</p>
  
  <p>Is there anyone who can help?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>debug($grades) outputs:
  
  Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [avg_grade] =&gt; 4.75000
                  )
  
              [sections] =&gt; Array
                  (
                      [section_name] =&gt; Nederlands
                  )
  
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [avg_grade] =&gt; 6.50000
                  )
  
              [sections] =&gt; Array
                  (
                      [section_name] =&gt; Engels
                  )
  
          )
  
  )
  </code></pre>