EquipmentUseId CollectionPointId EmployeeNum ShopOrder StartDateTime
366 69 9999 999999 4/26/13 3:29 PM
373 69 4878 107321 4/26/13 10:19 PM
385 69 4971 107321 4/27/13 7:35 AM
393 69 4179 107325 4/30/13 7:24 AM
394 69 4179 107325 4/30/13 7:38 AM
395 69 4179 107325 4/30/13 10:28 AM
398 69 4179 107325 4/30/13 2:41 PM
399 69 9999 999999 4/30/13 2:43 PM
400 69 9999 999999 4/30/13 2:46 PM
Given the above table, I'm left with a unique problem and describing it may be just as difficult. There is a StartDateTime for each ShopOrder per Employee but no StopDateTime, this is by design. However I need to be able to calculate the difference in time between the StartDateTime of one ShopOrder and the StartDateTime of the next ShopOrder. An example: SO # 999999 starts at 15:29 on 4/26 by Employee 9999, then a new SO # of 107321 is started at 22:19 on 4/26 by Employee 4878. I would need to calculate the difference between 4/26/2013 22:19 and 4/26/2013 15:29. This would give me the clock out date for SO# 9999 but it's actually need for a secondary process. For now I just need to be able get the time. One hang-up is if the SO #'s are the same then I would only use the first StartDateTime, and the first StartDateTime of the next SO #. Sorry this is so long, I'm not even sure if I've explained anything at this point.
Please go easy on me...it's been a long day.
Edited for output on 08/19/2013:
After mulling it over during the weekend, I decided it would be best to use an EndDateTime as this query is only the first step in the overall application/report.
Also, the EmployeeNum is not relevant anymore to this portion of the application.
This is how it should look (The EquipmentUseID is PK, the CollectionPointID is always 69 so they don't need to be shown on the output)?
ShopOrder StartDateTime EndDateTime 999999 4/26/13 3:29 PM 4/26/13 10:19 PM 107321 4/26/13 10:19 PM 4/30/13 7:24 AM 107325 4/30/13 7:24 AM 4/30/13 2:43 PM 999999 4/30/13 2:43 PM <next SO# StartDateTime>
To sum up this table, I need the SO#, the StartDateTime per SO# (already in the table), and the EndDateTime which is the actually the StartDateTime for the next SO#. Hopefully this clears it up, sorry for the confusion.