I have a table with numerous timestamps in (dd/mm/yyyy hh:mm:ss) format. I have worked out the calculations of specific time intervals which are updated for each record.
Each “job” may have any number of records associated with it. Each job is given a unique JobID number which is in alpha-numeric format. Eg. 0001-A. Records can be associated for the same job by comparing the Job ID number. If the numeric component is the same and the alpha is different (eg. Rows 1 & 2) then these records are for the same job.
Date,Job ID,Start Time,Time1,Time 2
01/01/2002,0001-A,01/01/2002 23:45:00,00:01:00, 00:05:00
01/01/2002,0001-B,02/01/2002 00:10:00,00:02:00, 00:03:00
02/01/2002,0002-A,01/01/2002 14:10:00,00:03:00, 00:05:00
What I need to do!
In the above example I need to run a query which will identify that the first two rows are associated to the same job and append the timestamps with the “lowest time elapsed” in Time 1 & Time2 to a separate table with just the numeric part of the Job ID.
Eg:
Date,Job ID,Start Time,Time1,Time 2
01/01/2002,0001,00:01:00,00:03:00
A problem I have is that the Job ID number is reset and may occur several times throughout the month but not within 24 hours of the “Start Time”. Also some timestamps may be recorded on different days ie. Before and after midnight.
Can anyone help me out? I have limited SQL knowledge and I’m not sure how to tackle the above.
Thanks in advance
Each “job” may have any number of records associated with it. Each job is given a unique JobID number which is in alpha-numeric format. Eg. 0001-A. Records can be associated for the same job by comparing the Job ID number. If the numeric component is the same and the alpha is different (eg. Rows 1 & 2) then these records are for the same job.
Date,Job ID,Start Time,Time1,Time 2
01/01/2002,0001-A,01/01/2002 23:45:00,00:01:00, 00:05:00
01/01/2002,0001-B,02/01/2002 00:10:00,00:02:00, 00:03:00
02/01/2002,0002-A,01/01/2002 14:10:00,00:03:00, 00:05:00
What I need to do!
In the above example I need to run a query which will identify that the first two rows are associated to the same job and append the timestamps with the “lowest time elapsed” in Time 1 & Time2 to a separate table with just the numeric part of the Job ID.
Eg:
Date,Job ID,Start Time,Time1,Time 2
01/01/2002,0001,00:01:00,00:03:00
A problem I have is that the Job ID number is reset and may occur several times throughout the month but not within 24 hours of the “Start Time”. Also some timestamps may be recorded on different days ie. Before and after midnight.
Can anyone help me out? I have limited SQL knowledge and I’m not sure how to tackle the above.
Thanks in advance