错误:调用未定义的函数SUM()

using cakephp2

$total = $this->order->find('all', array(
    'fields'     => array(SUM(order.vat)),
    'conditions' => $condition
));

SUM function is not working for me, am geeting error:

Call to undefined function SUM()

You need to write it like this,

$total = $this->order->find('all',array(
  'fields'=>array('SUM(order.vat) as total_vat'),
  'conditions'=>$condition
));

Add quotes around SUM(order.vat).

Here is another solution.

$this->order->virtualFields['total_vat']='SUM(order.vat)';

$total = $this->order->find('all',array(
  'fields'=>array('total_vat'),
  'conditions'=>$condition
));