Sort On Calculated Column

Hello everybody

i am trying to sort my database data by a calculated column

		$dataProvider = new CActiveDataProvider('Entries', array(


				'select' => 't.*, SUM(votes.value) AS test',

				'join' => 'join votes ON votes.type_id =',

				'condition' => 'votes.type = 0',

				'group' => '',



			'pagination'=>array('pageSize' => 30,)





in the view i have this:


// $dataProvider->sort->defaultOrder='$entry->test DESC';

$data = $dataProvider->getData();

foreach ($data as $entry)


	echo $entry->test."<br />";



But I always get this error message and i can’t figure out why:

Property "Entries.test" is not defined although it is in my select clause.

How am I able to sort my data on a calculated column?

Any help would be greatly appreciated.

did not have time to try coding, here is my idea:

  1. in your model define virtual property

public $test;

also add this property to your rule as normal property

  1. in your dataprovider [may not be necessarily, try it out]:






			'desc'=>'test DESC',




thank you very much, that fixed the problem :)