It depends on what you want to achieve… if you want to just fetch data and display it somehows - use CSqlDataProvider as it will be faster and possibly less resources consuming (memory, cpu time, etc).
On the other hand - when you want to use ActiveRecord capabilities on every fetched object - use CActiveDataProvider.
public function getCustomerList(){
$sql ="SELECT a.*,b.name as groupname
FROM `customer` as a
left join customer_group as b
on a.customer_group_id = b.customer_group_id";
$count = Yii::app()->db->createCommand('select COUNT(*) from customer')->queryScalar();
//make sql data provider
$dprov = new CSqlDataProvider($sql,array(
'totalItemCount'=>$count,
'keyField'=>'customer_id',
'pagination'=>array('pageSize'=>20),
'sort'=>array(
'attributes'=>array(
'firstname','lastname','groupname','email','date_added','status','telephone'
),
),
)
);
return $dprov;
}