有表如下:
id, QQ,日期  三个字段想统计出一个时间段内的报名人数,比如5月10日-5月20日每天的报人数。
(注:同一个QQ号一天内可能会报名很多次,这个是要忽略的,都按一个算).谁知肿么写...统计合拼

解决方案 »

  1.   

    select count(qq) from (select distinct qq,da from table) as table where da between unix_timestamp('2013-5-10') and unix_timestamp('2013-5-20');
      

  2.   

    select QQ,if(count(QQ)=0,0,1) as  counts from tab_name  where  日期  between  '2013-05-10'   and  '2013-05-20'    group by QQ 
      

  3.   

    额,上面那句是总的报名人数, 日期da时间戳格式; 
    select date_format(from_unixtime(da),'%Y-%m-%d') as date, count(qq) as num from (select distinct qq,da from table) as table  where da between unix_timestamp('2013-5-10') and unix_timestamp('2013-5-20') group by date;
      

  4.   

    select count(distinct qq) from 表名 between 开始时间 and 结束时间
      

  5.   


    select count(distinct qq) from 表名 where 时间字段 between 开始时间 and 结束时间
      

  6.   

    表字段(时间)是varchar或date类型 均可以使用"between . and ." 和 " >  ,<"直接比较,试试看吧,实践是检验真知的唯一标准!