我有这个查询,我想按数量总和订购。我必须在分页中使用这个结果,请帮助我..
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'));