解析函数问题

Analytical function issue

我正在处理历史处理问题。我正在编写一个查询来更新 start_date 的错误条目。 table中的数据如下:

Subs_is subs_cd     number  start_dt    end_dt
ABC 100 7854    10/8/2015   3/9/2015
ABC 100 58742   10/9/2015   20/09/2015
ABC 100 1278    23/09/2015  30/09/2015
ABC 100 4785    15/10/2015  25/10/2015

我希望 start_date 在数字更改时成为上一行 end_date。

谁能帮我解决这个问题。

此致, 阿米特

似乎是一个简单的LAG(在Teradata中没有实现,但很容易重写):

-- lag(start_date) -- not implemented
-- over (partition by Subs_is, subs_cd 
--       order by start_dt

-- previous row's value
max(start_dt)
over (partition by Subs_is, subs_cd 
      order by start_dt
      rows between 1 preceding and 1 preceding)