I am using CakePHP Find query to get SUM() from two diff fields in two diff db tables:
$total = $this->Model->find('all',array('fields' =>
array(
'SUM(Model1.amount * Model2.purchase * Model3.rental * Model4.manu) as total'),
'group' => array( 'Model.trackby_id' ) )
);
I have found sum() method useful for same tables two diff fields, but it does not seems working when two diff fields from diff tables.
Anybody have a solution for this?
You need to specify your SQL fragment in the fields array in the parameters of the find method.