我正在检索mlog
表的结果并在以下代码 1 的帮助下计算 的小计qtyn
。我不知道如何将我的第二个代码标准与第一个结合起来。
谢谢你的帮助
1.
SELECT autn, date, itcode, qtyn, out,
date, phstock,
qtyn + COALESCE(
(SELECT SUM(qtyn) FROM dbo.mlog b
WHERE b.autn < a.autn
AND itcode = '40'), 0) AS balance
FROM dbo.mlog a
WHERE (itcode = '40')
ORDER BY autn
2.
date >=(SELECT MAX([date]) FROM mlog)