esProc can solve this problem easily. It is just like Excel+SQL, a free tool, see: A Query Language Over-perform SQL [^]. code as below:
A1: =sqlsvr.query("select Name,Dates,[Outstanding Values] from test_table order by Name,Dates")
A2: =A1.derive(:Difference)
A3: =A2.group(Name)
A4: =A3.(~.run(Difference='Outstanding Values'-'Outstanding Values'[-1]))
I can't post a image file,so here are some explains: A1 cell:query some data from database. A2 cell:add a column to A1, named "Difference", just no data. A3 cell:group the data by field "Name" in A2 cell. Here are 3 groups, A4 cell:within every group(i.e. "~"), modify the field "Difference". The algorithm is: "this row" subtract "last row"(i.e. 'Outstanding Values'[-1]) I think esProc is more simple for mass data computation BTW. how to post a image file?