mysql - Get average time per a visit -


what i'm trying average page_visit_duration of rows have same session_id row duplicate session id means visitor visited multiple pages rows same session_id need add total page_visit_duration of pages visited before getting average time spent on site how can searched , couldn't find anything.

here's queries tried:

select avg(page_visit_duration) avgtime page_views   select avg(page_visit_duration) avgtime page_views group `session_id` 

please note second query returns many results need give 1 average

what i'm trying average time spent on our site per visitor.

you need first group results, , take average of those.

select avg(total_duration) avgtime     (select sum(page_visit_duration) total_duration, session_id page_views group session_id) sq 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -