7
我有這個查詢,我想用數量的總和來排序。我已經使用這個結果PAGINATE,請幫助我..如何在cakephp中使用聚合函數SUM?
SELECT (SUM(OrderItem.quantity)) AS qty, `OrderItem`.`item_name` ,
`OrderItem`.`size` FROM `order_items` AS `OrderItem` WHERE 1 =1
GROUP BY `OrderItem`.`item_name` , `OrderItem`.`size`
ORDER BY (SUM(OrderItem.quantity)) DESC
我已經試過代碼波紋管,但它不工作
$this->paginate = array('fields'=>array('(SUM(OrderItem.quantity)) as qty',
'OrderItem.item_name',
'OrderItem.size'),
'group'=>array('OrderItem.item_name','OrderItem.size'),
'order' => array('(SUM(OrderItem.quantity))'=>'DESC'));