0

mysql ステートメントで 2 つ以上カウントするのに問題があります。

count(b.entry_id) as totalbookingはうまくいきません。私は何を間違えましたか?ステートメントのセットアップも正しく行われていますか?

これは私が試した方法です:

"SELECT 
    t.restaurant_id as restaurant_id, ct.title as title, 
    count(DISTINCT t.cardid) as totalmembers, 
    count(t.restaurant_id) as totaltransactions, 
    count(b.entry_id) as totalbooking
    from transactions as t   
    inner join exp_menucard_booking as b on (t.restaurant_id = b.entry_id)
    inner join exp_channel_titles as ct on (t.restaurant_id = ct.entry_id)
    inner JOIN exp_channel_data as cd on (ct.entry_id = cd.entry_id)
    where t.cardid != 88888888 and ct.status = 'open'
    group by t.restaurant_id
    order by ct.title asc";
4

1 に答える 1

0

このパターンを使用して、行セット全体のサブセットをカウントします。

sum( case when ColumnToBeTested = trueCondition then 1 else 0 end) as SubCount
于 2013-04-14T12:47:33.523 に答える