CDbCriteria

$criteria = new CDbCriteria(); $criteria->select = '*, SUM(IF(type = 1, 1, 0)) AS sellersCnt'; $criteria->with = array('profile'); $criteria->together = TRUE; $sellersArray = User::model()->findAll($criteria);
$criteria->select = array("SUM(price) as price"); $criteria->with = array(); $result = self::model()->find( $criteria ); return $result->price;

Методы

Подробнее: http://www.yiiframework.com/doc/api/1.1/CDbCriteria#distinct-detail

SQL

select

alias = "t" (Алиас основной таблицы)

distinct = true, false (SELECT DISTINCT)

join = "join order o on t.order_id = o.id"

condition = "t.client_id=1"

group

having

order

limit

params = array()

Relations

together

with