附SQL如下
select
tableLead.pk_psndoc,
tableLead.begindate,
tableLead.enddate,
tableLead.pk_psndoc_sub,
CASE when (tableLead.pk_psndoc!=hi_psndoc_ctrt.pk_psndoc and hi_psndoc_ctrt.pk_psndoc is not null) then null else tableLead.p end pk_psndoc_subnext
from (
--lead当前的向下位移、lag当前的向上位移s
select pk_psndoc,begindate,ENDDATE,pk_psndoc_sub ,lead( pk_psndoc_sub ,1,0) over (order by pk_psndoc ,begindate) p from hi_psndoc_ctrt
--where pk_psndoc in (select pk_psndoc from bd_psndoc where name in ('张三','李四'))
--lead当前的向下位移、lag当前的向上位移e
)tableLead
LEFT OUTER JOIN hi_psndoc_ctrt on tableLead.p=hi_psndoc_ctrt.pk_psndoc_sub
where 1=1