所以,基本上我必须生成一个关于页面访问次数的报告。假设这是我的表格数据。(注意:请假设所有记录的日期时间值)
访问者dtime
a
c
b
a
d
b
e 2013-04-31 03:14:29
s 2013-04-01 03:14:29
a 2013-04-01 03 :14:29
b 2013-04-01 03:14:29
b 2013-04-01 03:14:29
c 2013-04-31 03:14:29
c 2nd
b 2nd
3rd
3rd
a 3rd
b 4th
b
因此,如果用户从中选择1st to 3rd
,我必须打印 Date PageLoads Unique Visits First time Visits Returning Visits
1st 4 3 1 2
2nd 3 2 0 2
3rd 3 2 0 2
pageloads for 1st are - s a b b
,unique visits - s a b
问题是找到第一次访问,这是唯一s
的,当与之前的每个访问者进行比较时。第二次第一次访问为 0,因为没有人第一次访问
我查找页面加载和唯一访问的查询是-
select distinct DATE(dtime) as ddate,count(visitors) as ploads,
count(distinct visitors) as uvisits,
from table1 where dtime >= '2013-04-1 00:00:01' and dtime <= '2013-04-3 23:59:59'
group by DATE(dtime) order by ddate desc;
如何找到每个日期的第一次访问?