title: How to use CStatRelation in Yii
body: <p>I am trying to find a way to collect data using <strong>sql</strong> aggregate functions like <em>max</em>, <em>min</em> and <em>count</em>.</p>
  
  <p>And I found that <em>CStatRelation</em> class seems to be what I want. <a href="http://www.yiiframework.com/doc/api/1.1/CStatRelation" rel="nofollow">CStatRelation</a> doc</p>
  
  <p>It can be used in the <em>relation</em> function in Yii's model class.</p>
  
  <p>The usage is like this:</p>
  
  <pre><code>class SomeModelClass extends CActiveRecord{
  
   public function relations() {
  
          return array(
              'bidCount'=&gt;array(self::STAT,'Bid','auction_id'),//it can be used like this
  
  
          );
      }
  }
  </code></pre>
  
  <p>The default value of the <em>rowCount</em> in the example code is the <em>count(*)</em>. But what if I want to find the <em>max/min</em> value of a specific column?? </p>
  
  <p>How can I modify the code to retrieve the max or the min??</p>