+ //@todo - this could be one query using the IF in mysql - eg
+ // SELECT sum(total_completed), sum(count_completed), sum(count_cancelled), sum(total_cancelled) FROM (
+ // SELECT civicrm_contribution.total_amount, civicrm_contribution.currency ,
+ // IF(civicrm_contribution.contribution_status_id = 1, 1, 0 ) as count_completed,
+ // IF(civicrm_contribution.contribution_status_id = 1, total_amount, 0 ) as total_completed,
+ // IF(civicrm_contribution.cancel_date IS NOT NULL = 1, 1, 0 ) as count_cancelled,
+ // IF(civicrm_contribution.cancel_date IS NOT NULL = 1, total_amount, 0 ) as total_cancelled
+ // FROM civicrm_contact contact_a
+ // LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id
+ // WHERE ( ... where clause....
+ // AND (civicrm_contribution.cancel_date IS NOT NULL OR civicrm_contribution.contribution_status_id = 1)
+ // ) as conts
+