1

Please look at this picture, All the required formula has been mentioned below the columns.

for better clarity my request is...

Column Name "E" : Item open in current month + historical open items (Previous months Sum)

Column Name "F" Warehouse : open items - closed items.

Need of SQL query.. Thanks in advance !

enter image description here

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
SQLMike
  • 57
  • 10

1 Answers1

-1

Take a look at these SQL Server built-in functions.

LAG

LEAD

This post has an example for previous value in SQL Server 2005 and 2012 (this one uses LAG function). How to get previous and current row value using recursive CTE?

Community
  • 1
  • 1