SELECT календарь.arcdate, [главная книга].otype, [главная книга].amount, (select sum(nz(a.otype*a.amount,0)) from [главная книга] as a where a.odate<=[календарь].arcdate) AS saldo
FROM календарь LEFT JOIN [главная книга] ON календарь.arcdate = [главная книга].odate
ORDER BY календарь.arcdate, [главная книга].otype DESC;
|