CakePHP在一个查询中多次计数

时间:2017-04-23 00:47:29

标签: cakephp cakephp-3.0

我希望在CakePHP 3中名为Posts的一个表中获得不同条件下的多个总计

这可能吗

计算post_sent,其中post_sent = 0

计算post_sent,其中post_sent = 1

计算rsvp,其中rsvp = 3

SELECT count(Case when post_sent=0 then 1 else 0 end) as post_not_sent, 
       count(Case when post_sent=1 then 1 else 0 end) as post_sent,
       count(Case when rsvp=3 then 1 else 0 end) as rsvp_sent
FROM content_form

0 个答案:

没有答案