[RESOLVED] Calculate Average Total Time Spent
Results 1 to 5 of 5

Thread: [RESOLVED] Calculate Average Total Time Spent

  1. #1
    Member
    Join Date
    Aug 2005
    Posts
    86

    resolved [RESOLVED] Calculate Average Total Time Spent

    Hello All,

    i have a script that records to a table some user information.

    1- session id
    2- page-visited
    3- timein
    4- timeout
    5- totaltime

    my question is how can i get the the average time users spend on a particular page (total average time spend on page), i already have the timein, timeout and total time information which is the result of comparing the timein and timeout records.

    Any help is greatly appreciated, thanks.

  2. #2
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,943
    Should work in MySQL, not sure how portable it is to other DBMS's:
    Code:
    SELECT page-visited, AVG(totaltime) AS avg_time FROM table_name GROUP BY page-visited
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  3. #3
    Member
    Join Date
    Aug 2005
    Posts
    86
    Quote Originally Posted by NogDog
    Should work in MySQL, not sure how portable it is to other DBMS's:
    Code:
    SELECT page-visited, AVG(totaltime) AS avg_time FROM table_name GROUP BY page-visited

    Thanks NogDog,

    Im assuming the result i get is in seconds format and all i need now is convert this to time format?
    Last edited by 1042; 01-31-2008 at 04:16 PM.

  4. #4
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,943
    It would be in whatever unit you use for the totaltime field.
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  5. #5
    Member
    Join Date
    Aug 2005
    Posts
    86
    Thanks NogDog, that worked like a charm.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •