Given the following diagram:

With the code below I have the Donations grouped for each organization now I am trying to calculate the total amount a given member has donated to a given organization.
Something like:

With this code it correctly groups that organizations as I need but the problem I have here is that for the 'Amount Donated to Organization' column all values equal the total of the Organization with the highest Id. Therefore all rows in that column are showing $90
Yii Code:
// member view
<?php
$dataProvider=new CActiveDataProvider(Donation::model(), array(
'criteria'=>array(
'with' => array(
'member' => array(
'on'=>'member.MemberId='.$model->MemberId,
'group' => 't.MemberId, t.OrganizationId',
'joinType'=>'INNER JOIN',
),
),
'together'=> true,
),
));
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns' => array(
array(
'name'=>'OrganizationId',
'value' => '$data->OrganizationId',
),
array(
'name'=>'Amount',
'value' => '$data->memberOrgBalance;',
),
),
));
?>
// member model
'memberOrgBalance' => array(self::STAT, 'Donation', 'MemberId',
'select'=>'MemberId, OrganizationId, SUM(Amount)',
'group' => 'OrganizationId'),
// donation model
'member' => array(self::BELONGS_TO, 'Member', 'MemberId'),
EDIT: See also response to LDG
Using the advice from LDG I tried adding 'having' to my dataprovider, when that did not seem to affect the query I tried to add it to the relation memberOrgBalance where I am trying to pull the data. This seems to affect the query but it is still not right. I switched to:
'memberOrgBalance' => array(self::STAT, 'Donation', 'MemberId',
'select'=>'MemberId, OrganizationId, SUM(Amount)',
'group' => 'OrganizationId',
'having'=> 'MemberId=member.MemberId',
),
which gives this error:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]:
Column not found: 1054 Unknown column 'member.MemberId' in 'having clause'.
The SQL statement executed was: SELECT `MemberId ` AS `c`, MemberId, OrganizationId,
SUM(Amount) AS `s` FROM `donation` `t` WHERE (`t`.`MemberId `='2')
GROUP BY `MemberId `, OrganizationId HAVING (MemberId=member.MemberId)
This makes no sense since from the donation table I have the relation defined as originally posted above. The query seems to be going the direction needed to get the SUM per organization as I want though. Any other ideas?