Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Total Time duration

 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ALL,
I need to get total time duration of my user in my application. I got maximum time duration he has spent for a month from the below sample query .




The output I got as below:
siteDuration---------------->::00:00:24
siteDuration---------------->::00:00:05
siteDuration---------------->::00:00:09
siteDuration---------------->::00:00:14
siteDuration---------------->::00:51:33
siteDuration---------------->::00:16:42
siteDuration---------------->::00:00:05
siteDuration---------------->::00:00:25
siteDuration---------------->::00:00:05
siteDuration---------------->::00:00:10
siteDuration---------------->::00:00:09
siteDuration---------------->::00:03:02
siteDuration---------------->::00:00:18
siteDuration---------------->::00:00:11

I need to total all the times mentioned above and get the result as total duration time. How it is possible in java?
I have tried with Sum function in SQl, but it will not total the time(HH:MM:SS), it can total only the integer values. The resultset i am getting is set of all the max time duration the user has spent for a month, so i need to total all the values and get the output as single Time in HH:MM:SS format.
Help in java code is appreciated.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simplifying your statement (removing needless intermediate StringBuffer):



I'm asking, how this query might return multiple rows?
You don't have a GROUP clause, so SELECT MAX (x) FROM (y) should return just one value - the maximum.

Probably you're hiding something here?

and you tried

without success?
 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the fully query is not important. The resultset i am getting is set of all the max time duration the user has spent for a month, so i need to total all the values and get the output as single Time in HH:MM:SS format. Hope this clarifies your doubts. This is my query:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic