sql case when学习

select count(1) as totalCnt,
count(case when op.match_status in (1,3) then 1 end) as matchCnt,
count(case when op.match_status in (1,3) and op.crawl_time<adddate(now(),interval -1 day) then 1 end) as deadCnt
from opponent_product op
where op.enabled=1
and op.opponent_id=5

原文地址:https://www.cnblogs.com/lexus/p/2650576.html