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

前端 未结 2 1278
夕颜
夕颜 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
    
    0 讨论(0)
  • 2021-01-23 16:49
    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
    
    0 讨论(0)
提交回复
热议问题