7,732
社区成员




SELECT year(t.dt) as 年,month(t.dt) as 月,day(t.dt) as 日,b.h as 时,count(*) as 访问数
from t1 t right join(
select distinct hour(dt) as h from t1
)b on hour(t.dt)=b.h
where not exists(select 1 from t1 where ip=t.ip and year(dt)=year(t.dt)
and month(dt)=month(t.dt) and day(dt)=day(t.dt) and hour(dt)<hour(t.dt))
group by year(dt),month(dt),day(dt),b.h
SELECT year(dt) as 年,month(dt) as 月,day(dt) as 日,hour(dt) as 时,count(*) as 访问数
from t1
group by year(dt),month(dt),day(dt),hour(dt)
select hour(日期),count(*)
from 表如下:
group by hour(日期)
ip 日期
42.168.2.5 2011-10-23 00:17:21
88.68.23.56 2011-10-23 00:57:21
142.68.4.33 2011-10-23 01:11:26
192.138.2.6 2011-10-23 01:26:22
92.178.22.57 2011-10-23 08:40:25
132.188.21.205 2011-10-23 12:30:28
195.148.28.58 2011-10-23 14:26:23
182.128.82.95 2011-10-23 23:27:29