转载自:https://segmentfault.com/q/1010000009082729
select team_name,count(if(score='正','正','')) as'正',count(if(score='负','负','')) as '负' from teamscore group by team_name;
结合我自己的项目
想要把 同一positionId,和materialId 根据isClick true 和false 按照日期 进行统计
select positionid,materialid,sum(if(isclick='true',1,0)) as'clickcount',sum(if(isclick='false',1,0)) as 'displaycount'
from ads_log_record where recordTime between '1804160900' and '1804161030' and positionid = '4'
group by positionid,materialid
想要结果如下