问题:统计指定月份的每天/每小时的访问次数的2条sql语句表结构及数据:id ip c_date
1 127.0.0.1 2006-08-09 10:55:46.000
2 127.0.0.1 2006-08-09 10:56:43.000
4 127.0.0.1 2006-08-10 09:33:23.000
.
.
.我只会写每天所有的统计,但不能按月进行每天的统计:
select c_date=convert(char(10),c_date,120),count_click=count(*) from TadCount where ad_id=29 group by convert(char(10),c_date,120)
1 127.0.0.1 2006-08-09 10:55:46.000
2 127.0.0.1 2006-08-09 10:56:43.000
4 127.0.0.1 2006-08-10 09:33:23.000
.
.
.我只会写每天所有的统计,但不能按月进行每天的统计:
select c_date=convert(char(10),c_date,120),count_click=count(*) from TadCount where ad_id=29 group by convert(char(10),c_date,120)
count_click=count(*)
from TadCount
where ad_id=29
group by day(c_date)
1)每月的统计
2)指定月份的每天统计
3)指定月份的每天中的每小时统计
先谢过,你的sql语句是按1~31天统计所有次数,并没有按指定月份,比如8月或者7月
c_date=day(c_date),
count_click=count(*)
from TadCount
where ad_id=29
group by month(c_date),day(c_date)
比如:我指定了8月,统计就是从8.1~31号的所有访问次数,结果按1~31号分组,如:2006-08-01 2
2006-08-02 11
2006-08-03 2
.
.
.
2006-08-31 6
from TadCount
where c_date>='2006-8-1' and c_date<'2006-9-1'
group by c_date