Well, you need to change only one value to get correct result:
CARKOD ISLTARIH TARIH KAYITNO BORC ALACAC BAKYIE
12001001 2020-03-21 15:41:19 2020-03-01 3 500 500
12001001 2020-03-21 16:09:16 2020-03-05 4 600 1700
12001001 2020-03-21 16:09:16 2020-03-03 8 600 1700
12001001 2020-03-21 22:20:51 2020-03-20 5 -500 1200
12001001 2020-03-21 23:03:44 2020-03-30 6 -500 700
12001001 2020-03-21 23:03:45 2020-03-30 7 -500 200
In your original file underscored value is:
2020-03-21 23:03:44
, so
SUM(TUTAR)
for the financial operation made in the same second is 1000! That's why you've got the value of 200 instead of 700.
Here is a query used by me:
SELECT src.CARKOD, src.ISLTARIH, src.TARIH, src.KAYITNO, IIF(src.BA='B', src.TUTAR, NULL) AS BORC, IIF(src.BA='A', src.TUTAR*-1, NULL) AS ALACAC, (SELECT SUM(IIF(ps.BA='B', ps.TUTAR, ps.TUTAR *-1))
FROM CARTH001 AS ps
WHERE ps.ISLTARIH <= src.ISLTARIH) AS BAKYIE
FROM CARTH001 AS src
ORDER BY src.ISLTARIH, src.KAYITNO;
[EDIT]
Accordingly to the comments to this answer...
A query should looks like:
SELECT src.CARKOD, src.ISLTARIH, src.TARIH, src.KAYITNO, IIF(src.BA='B', src.TUTAR, NULL) AS BORC, IIF(src.BA='A', src.TUTAR*-1, NULL) AS ALACAC
FROM CARTH001 AS src
ORDER BY src.TARIH, src.ISLTARIH;
The rest have to be done in MS Excel, because MS Access does not support
ROW_NUMBER(PARTITION BY ... ORDER BY ...)
. Although it is available to achieve by several subqueries, but final solution is - at least - ugly...
I've created MS Excel file, which gets data from Access database and "calculate" pending sum based on it.
Excel - pending sum on Access data[
^]
File is available to download between 07:00AM and 10:59.59PM UTC+1 (Warsaw)
Result:
CARKOD ISLTARIH TARIH KAYITNO BORC ALACAC BAKYIE
12001001 2020-03-11 2020-03-01 3,00 500,00 500
12001002 2020-03-15 2020-03-01 1,00 -500 0
12001001 2020-03-10 2020-03-03 8,00 600,00 600
12001001 2020-03-12 2020-03-05 4,00 600,00 1200
12001001 2020-03-22 2020-03-05 13,00 -400 800
12001001 2020-03-20 2020-03-15 12,00 300,00 1100
12001001 2020-03-13 2020-03-20 5,00 -500 600
12001001 2020-03-18 2020-03-20 10,00 750,00 1350
12001001 2020-03-19 2020-03-20 11,00 30,00 1380
12001001 2020-03-14 2020-03-30 7,00 -500 880
12001001 2020-03-16 2020-03-30 9,00 -500 380
12001001 2020-03-17 2020-03-30 6,00 -500 -120