question

msridha2 avatar image
msridha2 asked

SQL code for using preceding values

Hi I need the value in 'Needed' column, logic is provided below

sqlcode
capture.png (43.1 KiB)
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Jeff Moden avatar image
Jeff Moden answered

Lookup up the LAG function (teaching someone how to fish) if you're using at least SQL Server 2012. Actually, here's the link ...

https://www.google.com/search?q=lag+in+sql+server


10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.