周郑

没有任何排序记录,按照某个字段排序后,找到当前行及其下一行数据

发布时间:3年前浏览量: 1663 ℃评论数:暂未开放

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


Oracle

微信扫码打赏

打赏排行榜

| 施主 | 时间 | 方式 | 金额 |

曾 俊 2020-02-16 微信打赏 ¥10.00

王 强 2020-01-24 微信打赏 ¥5.00

莫国成 2019-07-20 微信打赏 ¥ 50.00

说明:打赏记录每日24:00:00更新,50%用于无名公益!

1 2 3

手机扫码访问