title: How to add this complex query into CDbCriteria (Yii 1.x)
body: <p>I am trying to run the following query but run this through Yii's own CDbCriteria so it can work alongside some other queries that are using the Yii CDbCriteria functionality.</p>
  
  <p>I'm not sure how i'd do the following SQL query using the CDbCriteria can anyone assist?</p>
  
  <pre><code>SELECT *
  FROM
  students t1
  WHERE school_id = 1 
  AND
  (
      SELECT
          sum(points)
      FROM
          students t2
      WHERE
          t2.id &lt;= t1.id
  ) &gt;= 1000
  ORDER BY id
  LIMIT 1
  </code></pre>