select a.* from testip a
inner join (
SELECT convert(varchar(7),date,23) as date FROM testip group by convert(varchar(7),date,23)) b
on a.date=b.date
where b.date='2014-04'

解决方案 »

  1.   

    convert在mysql下不是这个用法,你的环境是sqlserver
      

  2.   

    SELECT convert(varchar(7),date,23) as date,count(distinct username) FROM testip group by convert(varchar(7),date,23)
      

  3.   

    select * from testip where convert(varchar(7),date,23)='2014-04'??
    最好给出你的表结构
      

  4.   


    -- 查询2014-04月访问的人
    select * 
     from testip
     where convert(varchar(7),[date],23)='2014-04'
      

  5.   


    -- 查询2014-04月访问的人
    select * 
     from testip
     where [date] between '2014-04-01 00:00:00' and '2014-04-30 23:59:59'
      

  6.   


    select [ip], count(ip)  as 访问次数
     from testip
     where [date] between '2014-04-01 00:00:00' and '2014-04-30 23:59:59'
    group by [ip]