得到了这个SQL:
select count(*), FKP_FD_RID, FKP_KEYWORD from filekeypairattib
where fkp_fd_rid > 0 and fkp_fd_rid < 1000000
group by FKP_FD_RID, FKP_KEYWORD having count(*)>1
需要知道返回了多少count()?不是每组中有多少,而是总数。
无法做对。
答案 0 :(得分:0)
- 如果您需要总计数作为每组计数的摘要
$tasks_done = ProjectHasTask::all(array('conditions' => array('status = ? AND project_id = ? AND due_date <= ? AND due_date >= ?', 'done', $project_id, $from_date->getTimestamp(), $to_date->getTimestamp())));
- 如果您需要原始查询中的行数
select sum(cnt) over (), s.*
from(
select count(*) cnt, FKP_FD_RID, FKP_KEYWORD from filekeypairattib
where fkp_fd_rid > 0 and fkp_fd_rid < 1000000
group by FKP_FD_RID, FKP_KEYWORD having count(*)>1
) s