【发布时间】:2015-02-25 10:56:58
【问题描述】:
有没有一种方法可以使用前导函数,这样我就可以获得发生变化的下一行,而不是相同的地方?
在这个例子中,RowType 可以是“in”或“out”,对于每个“in”,我需要知道它变成“out”的下一个 RowNumber。我一直在玩主角功能,因为它真的很快,但是我无法让它工作。我只需要真正执行以下操作,即按不是当前行中的 RowType 进行分区。
select
RowNumber
,RowType --In this case I am only interested in RowType = 'In'
, Lead(RowNumber)
OVER (partition by "RowType = out" --This is the bit I am stuck on--
order by RowNumber ASC) as NextOutFlow
from table
order by RowNumber asc
提前感谢您的帮助
【问题讨论】: