char *mon;
for(int i=0;i<=12;i++)
{
  sprintf(mon,"%d",i);
  select count(*) from tablename where date_format(datevalue,'%m')=mon 
  
}

解决方案 »

  1.   

    增加一个统计表方便一些。数据需要你自己初始化。
    TABLE stat
    id    date(年-月)   记录数
    1      200405        0
    2      200406        0
    3      200407        0
    4      200408        0
    5      200409        0
    6      200410        0这样就可以查询了。UPDATE stat
    SELECT COUNT(*) FROM data_table WHERE data_table.date = stat.date ...;统计出来的数据还可以重复使用具体SQL自己写。
    只是给你出个主意而已。