Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3165

Re: How to calculate Surplus w.r.t the previously changed value?

$
0
0

Hi Nithin,

 

I am ordering by ID. I am not able to track the changes. My problem will be solved if I am able to track the change.

t.PNG

427- 300 = 127, But my requirement is to take the changed value: 713 - 300 = 413

 

I have used something like this:

SELECT ID,PRODUCTID,RECEIPTQTY,FIXEDPEGGEDQTY, SURPLUSSHORTAGEQTY ,

COALESCE(LAG(SURPLUSSHORTAGEQTY) over (partition by PRODUCTID order by ID), RECEIPTQTY   ) - FIXEDPEGGEDQTY as SURPLUSSHORTAGEQTY

 

Regards,

Mayur


Viewing all articles
Browse latest Browse all 3165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>