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'
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'
最好给出你的表结构
-- 查询2014-04月访问的人
select *
from testip
where convert(varchar(7),[date],23)='2014-04'
-- 查询2014-04月访问的人
select *
from testip
where [date] between '2014-04-01 00:00:00' and '2014-04-30 23:59:59'
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]