[英]Difference between two rows in sql
How to calculate difference between two rows in sql developer??如何计算 sql 开发人员中两行之间的差异? Scenario is Employee1 has two tasks so I need to calculate the difference between the start date of task1 and finish date of task2 And in 3rd row again Employee2 has two tasks so I need to calculate that difference too.
场景是 Employee1 有两个任务,所以我需要计算 task1 的开始日期和 task2 的完成日期之间的差异。在第三行,Employee2 有两个任务,所以我也需要计算这个差异。 Can someone help me in this please...
有人可以帮助我吗...
If I understand correctly, you want lag()
:如果我理解正确,您需要
lag()
:
select t.*,
start_date - lag(end_date) over (partition by employee order by start_date) as diff
from t;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.