标签: sql oracle
如何添加另一列,第二行和第三行之间的差异,而不是第三行和第四行,依此类推。提前谢谢!
答案 0 :(得分:2)
使用lag():
lag()
select d.*, (department_id - lag(department_id) over (order by department_id)) as diff from departments d;