1SELECT t1.OrderNo,DATEDIFF(day,t1.LoadedStartDate,t2.LoadedStartDate)
2FROM UnnamedTableFromQuestion t1
3 INNER JOIN
4 UnnamedTableFromQuestion t2
5 on
6 t1.OrderNo = t2.OrderNo
7WHERE t1.OpNo = 1 and
8 t2.OpNo = 4
9
10////////////////////////////////////////////////////////////////
11
12select cur.unique_id_field, cur.seq_no, cur.date_created ,
13
14 datediff(second, prv.date_created, cur.date_created) as diff_in_seconds
15
16from yourtable as cur
17
18 join yourtable as prv
19
20 on cur.seq_no = prv.seq_no + 1;