Time difference among end dates of first records to next record first dates

前端 未结 2 1282
夕颜
夕颜 2021-01-23 16:17

How to find the dates difference in minutes among different columns levels as

No SourceID  RecordID  Start Date               End Date
1  1         1         20         


        
2条回答
  •  暖寄归人
    2021-01-23 16:39

    SELECT SourceId,
           RecordId,
           StartDate,
           EndDate,
           DATEDIFF(mi,a.EndDate,b.StartDate) DiffMin
    FROM table a
    LEFT JOIN table b ON A.no = B.no-1
    

提交回复
热议问题