I will show you a problem I am facing. I would like to have the last value of columns until the next value is smaller or zero In the next image I hope to explain my problem more easily:
So, every time the value of "PartA" is greater than the next one, that value should be shown.
Can someone help me, please?
CodePudding user response:
You can use lead() function for this,
select id,parta,partb,time from
(
select
id
,parta
,partb
,lead(parta) over (partition by id order by lineitem) nextval
from sample_stk
)A
where parta>nextval