我想估算用户在外部链接上停留的时间。因此,我希望看到他们单击外部链接的时间与他们下次单击我的网站的时间之间的区别。
我的数据库如下所示(说明了重要的列):
到目前为止,我已经确定了所有具有> 1 clsfd_event_action的会话。但是,我很难筛选出该会话必须具有外部链接单击以及其他clsfd_event_action(s)。
select clsfd_session_id, count(*)
from table
group by 1
having clsfd_session_id> 1
我想要的是所有具有外部链接单击的会话(= R2SExternalBegin),然后是另一行(以便会话不会结束,但访问者返回我的站点)。
在下面的图片中,您可以看到 1个会话,包括1个外部链接单击(R2SExternalBegin),然后是1 /更多行(因此该会话不会在外部链接处结束)。红色矩形最后一列中数字之间的差异是在外部链接上花费的时间。
我想要的输出 具有1 /个以上R2SExternalBegin clsfd_event_action的所有会话,其后是另一行(这意味着用户返回该站点)。请注意,大约有50种不同的clsfd_event_actions。
答案 0 :(得分:0)
select clsfd_session_id, count(*)
from table
group by 1
having
-- there was a 'R2SExternalBegin'
min(case when clsfd_event_action = 'R2SExternalBegin' then hit_start_time_num end)
-- and there was different action later
< max(case when clsfd_event_action <> 'R2SExternalBegin' then hit_start_time_num end)