Yii criteria group and order


How we can fetch last data (in descending order data fetch) after group and order? I fetch the data with the following code and its return the first data after order. I need to fetch from last.

$criteria   =   new CDbCriteria;                

$criteria->condition= 'from_user=:user OR to_user=:user';

$criteria->params= array(':user'=>  Yii::app()->user->id);                       

$criteria->group= 'chat_id';

$criteria->order= 'created_at DESC'; 

Using this sql, it returns correct way

SELECT * FROM ( SELECT * FROM `chat_messages` ORDER BY `created_at` DESC ) AS tmp_table GROUP BY `chat_id`