Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:23:56+00:00 2026-06-13T17:23:56+00:00

I have a mysql table with the following fields: _id , userId , objectId

  • 0

I have a mysql table with the following fields:

_id, userId, objectId, timeStamp

I want to calculate the total time an object was interacted with by all users.

I created the query that calculates the time difference between a row and its subsequent row but this doesn’t take into consideration the order of actions by a given user. That query looks like this:

SELECT A._id, A.USERID, A.objectid, A.timeStamp,
    SUBSTRING(A.timeStamp, 12, 2) as hourOfDay,
    TIME_TO_SEC(TIMEDIFF(B.timeStamp, A.timeStamp)) as diff 
FROM InteractionsTBL A 
INNER JOIN InteractionsTBL B ON B._id = (A._id + 1) and B.USERID = A.USERID 
where A.timeStamp > '2012-04-18 1:00:00'
and A.timeStamp < '2012-04-18 23:59:00' 
group by hourOfDay, A.objectid 
ORDER BY A._id ASC

How do I calculate the sum total of time interaction with an object by all users grouped by the hour of the day and the objectId?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:23:58+00:00Added an answer on June 13, 2026 at 5:23 pm

    I ended up writing a pearl script to go in and calculate this difference after the fact. I’m not sure if this is possible in real time with SQL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mysql table called pics, with the following fields and sample
I have a 'Comments' MySQL table that has the following fields: id text parent_id
I have a MySQL table with the following fields: Email, Flag1, Flag2 The question:
I have mysql table with following fields id (which auto increments) title,name,age,institution,iod the fields
I have a simple table in mysql with the following fields: id -- Primary
I have a MySQL table with the following fields: id, morning, evening, event, other-fields
I have a simple mysql table called messages with the following fields: ID(int) MESSAGE(varchar)
I have a MySQL table (table1) with following fields... id, title, description, detail, category,
Let's assume I have 3 tables in a MySQL table with the following fields.
I have a (MySQL) table with two date/time fields: start and end (each of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.