select
count(*) as mcount ,
left(create_time,10) as ptime ,
count(if(receive_msg is null,id,null)) as nullcount ,
count(if(receive_msg = '1',receive_msg,null)) as apfcount ,
count(if(receive_msg = '2',receive_msg,null)) as dttcount ,
count(if(receive_msg = '3',receive_msg,null)) as dicount
from
t_votes
where
left(create_time,7)>='$pearly'
and
left(create_time,7)<='$plate'
group by
ptime ;
COUNT(*)´øÉÏֵΪNULLµÄ
COUNT(table_name)²»´øÖµÎªNULLµÄ
¼ÆÊý²»ÇóºÍ,¿ÉÓÃÆäËû×Ö¶ÎÌæ´ú
select
count(*) as mcount ,
left(create_time,10) as ptime ,
SUM(if(receive_msg is null,id,0)) as nullcount ,
SUM(if(receive_msg = '1',receive_msg,0)) as apfcount ,
SUM(if(receive_msg = '2',receive_msg,0)) as dttcount ,
SUM(if(receive_msg = '3',receive_msg,0)) as dicount
from
t_votes
where
left(create_time,7)>='$pearly'
and
left(create_time,7)<='$plate'
group by
ptime ;
SUMÇóºÍ,×îºóÒ»¸ö²ÎÊý¸ÄΪ0.¾ßÌåÔÒò²»Ã÷