[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
    14,478
    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
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  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
    14,478
    It would be in whatever unit you use for the totaltime field.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  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
  •