Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB2 Advanced Query

Status
Not open for further replies.

luiscantor

Programmer
Joined
Sep 26, 2013
Messages
1
Location
US
Hi Programers,

Could you support me with a question that I could not solve?
Need to get the total time for each group, for example CREATE_TIMESTAMP column contains some time values ​​process. The ID column contains the classification of the process.

|_______ID______|_____MODEL______|_____________ CREATE_TIMESTAMP_________________
A A1 8/27/2013 12:57:05
A A1 8/29/2013 14:40:45
B B1 8/27/2013 7:04:49
B B1 8/27/2013 8:06:57
B B1 8/27/2013 9:06:57
B B1 8/27/2013 9:07:00
C C1 8/30/2013 1:28:36
C C1 8/30/2013 2:10:36
C C1 8/30/2013 2:13:40

I need to make a query to DB2 throws me the following information, based on the before table

|_______ID______|_____MODEL______|_____________TOTAL TIME_______________
A A1 2984:40
B B1 122:11
C C1 45:04


45:06 means---> 45 minutes, 6 seconds


Regards
 

hi,
Code:
select id, model, max(CREATE_TIMESTAMP)-min(CREATE_TIMESTAMP)
from ....
is the basic query. the difference is the duration in DAYS.

It seems strange to report the results in minutes & seconds when there are DAYS & HOURS that can be displayed as HOURS:MIN:SEC otherwise report as minutes only.



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top