如何使用 cakePhp find()和条件重现以下查询?
SELECT a, SUM(bTotal) as fullTotal FROM
(SELECT a, SUM(b) * c as bTotal FROM Table1
GROUP BY a)
GROUP BY a
一般来说,我如何在 cakePhp 中编写嵌套组?
编辑:
我可以通过以下方式用单个组编写它:
$results = $this->Vote->find('all', array('fields' => array('Choice.Answer', '(COUNT(Vote.id) * User.voteMultipler) AS voteTotal', 'choice_id', 'user_id'),
'group' => 'choice_id, Vote.user_id',));
我想按Answer对结果进行分组和求和。