I am using an older version of sybase which does not have keywords like lead.
I want to find cumulative left over.
Let me try to explain this with an example.
StartQuantity = 500
Category Time Quantity LeftOver cat1 10:01:01.000 100 400 cat1 10:01.01.001 50 350 cat1 10:01:01.002 0 350 cat1 10:01.01.003 100 250 cat1 10:01:03.001 100 150
Similar rows are available in cat2 and the number of rows per category is variable.
Please note that in above I have arranged the rows in ascending order of time.
I don’t know if Sybase supports this, but in PostgreSQL, Oracle and others you can do