استخدم هذه الجملة في استعلام
SELECT t1.id, t1.CurrencyType, t1.Credit, t1.Debit, (SELECT SUM(t2.Credit - t2.Debit)
FROM trans t2
WHERE t2.CurrencyType = t1.CurrencyType
AND (t2.id <= t1.id)) AS CumulativeBalance, t1.id
FROM trans AS t1
ORDER BY t1.id;
غير trans حسب اسم الجدول لديك