SQL query to identify paired items (challenging)
===

Assume there is a relation database with one table:

    {datetime, tapeID, backupStatus}

    2012-07-09 3:00, ID33, Start
    2012-07-09 3:00, ID34, Start
    2012-07-09 3:00, ID35, Start
    2012-07-09 4:00, ID34, End
    2012-07-09 4:00, ID33, Start
    2012-07-09 5:00, ID33, End
    2012-07-09 5:00, ID34, Start
    2012-07-09 6:00, ID34, End
    2012-07-10 4:00, ID35, Start
    2012-07-11 5:00, ID35, End


tapeID = any of 100 different tapes each with their own unique ID.

backupStatus = one of two assignments either Start or End.

I want to write a SQL query that returns five fields

    {startTime,endTime,tapeID,totalBackupDuration,numberOfRestarts}
    2012-07-09 3:00,2012-07-09 5:00, ID33, 0days2hours,1
    2012-07-09 3:00,2012-07-09 4:00, ID34, 0days1hours,0
    2012-07-09 3:00,2012-07-10 5:00, ID35, 0days2hours,1
    2012-07-09 5:00,2012-07-09 6:00, ID34, 0days1hours,0
    2012-07-10 4:00,2012-07-11 5:00, ID35, 1days1hours,0


I'm looking to pair the start and end dates to identify when each backupset has truely completed.  The caveat here is that the backup of a single backupset may be restarted so there may be multiple Start times that are not considered complete until the following End event.  A single backupset may be backed up multiple times a day, which would need to be identified as a with a separate start and end time.

Thank you for your assistance in advance!
B