简体   繁体   English

导致 sql 中的 function 无法按预期工作

[英]lead function in sql not working as expected

I am using the following query to identify the newEndDate我正在使用以下查询来识别 newEndDate

在此处输入图像描述

But, the result i get is但是,我得到的结果是

在此处输入图像描述

Why am i not getting newEnddate for the last row?为什么我没有得到最后一行的 newEnddate? please help请帮忙

You can use same column in lead() in last parameter:您可以在最后一个参数中使用lead()中的同一列:

lead(se.status_startdt, 1, se.status_startdt) over (partition by se.invoice_number order by se.status_startdt)

As per sample data this seems to be use of coalesce() :根据样本数据,这似乎是使用coalesce()

coalesce(se.status_enddt, se.status_startdt)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM