Calculate time difference between rows
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: Calculate time difference between rows

Threaded View

  1. #1
    Join Date
    Apr 2008
    Posts
    3

    Question Calculate time difference between rows

    Hi,

    I have record stored as shown, (Please find attached file if format not clear)

    SHIPMENT_ID MESSAGE_TYPE CREATED_DTTM
    9336 5 9/29/2006 9:16:14 AM
    9336 10 9/29/2006 10:33:16 AM
    9379 5 10/5/2006 11:43:33 AM
    9379 10 10/6/2006 7:19:38 AM
    10128 5 10/3/2006 8:21:25 AM
    10128 10 10/4/2006 10:20:03 AM

    and using SQL would need to calculate time difference between message_type 5 and 10 for each Shipment_id.

    (9/29/2006 9:16:14 AM) - (9/29/2006 10:33:16 AM)

    (10/5/2006 11:43:33 AM) - (10/6/2006 7:19:38 AM)

    (10/3/2006 8:21:25 AM) - (10/4/2006 10:20:03 AM)

    Expecting results in format after calculating time difference from above for each shipment_id,

    SHIPMENT_ID TIME_DIFFERENCE

    9336
    9379
    10128

    Thanks,
    Siva
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width