mysql count 各种情况 case when



select a.num  , a.success  , a.num - a.success as fail
from 
(
SELECT   
count(1) AS num,  
count(case when detail_voucher_id is not null then detail_voucher_id end ) AS success
FROM fm_account_recharge 
where date_format(pay_finish_time, '%Y-%m-%d') = date_format('2018-02-24','%Y-%m-%d') 
and recharge_mode = 1 
) a

猜你喜欢

转载自dannyhz.iteye.com/blog/2413665