how can i use date difference between two asymmetric row from same table?
where ([realtime] is not null) and ([endtime] is not null and)
order by [realtime]
DateDiff function to get the difference between two dates.
day parameter to get the difference in days.
SELECT [endtime] ,[realtime] ,datediff (day,[endtime],lead ([realtime]) over (order by [realtime])) as days_endtime_2_next_realtime FROM [prin] WHERE ([realtime] is not null) AND ([endtime] is not null) ORDER BY [realtime]