I have been at this issue on and off for the past week hoping I would find a solution.
My Goal is based around organising statistics for marketing pages by a website stat generator, in short I would like to create a summary of the last page the visitors were viewing when they left.
The query is able to group all the pages together by the session_id and display the last page viewed, however I’m having the difficulty grouping the results further by the pagename, since at the moment duplicate page names are being displayed (for each unique session where the visitor left on the same page)
The query as follows
Expand|Select|Wrap|Line Numbers
- select max(p.date_viewed)as last, count(distinct p.session_id) as cnt, p.pagename, p.session_id from page_test p
- inner join session_test s
- on(s.session_id=p.session_id and s.time_visit>$start_date and s.time_visit<$end_date and s.promotion='$promotion')
- group by p.session_id order by cnt desc limit 10
page_test
Page_id | session_id | pagename | date_viewed
session_test
session_id | visitor_id | time_visit | promotion
Thanks in advance for any help
Mark