I need to check SUM(rf.rmstranamt) for positive or negative
Rules should be:
If SUM(rf.rmstranamt) is negative
SUM(rf10.rmstranamt10) + SUM(rf.rmstranamt) AS [Balance]
If SUM(rf.rmstranamt) is positive
SUM(rf10.rmstranamt10) - SUM(rf.rmstranamt) AS [Balance]
instead of how I am just subtractive everything below no matter if SUM(rf.rmstranamt) which is not right because I'll produce false positives
SELECT rm.rmsacctnum AS [Rms Acct Num],
SUM(rf.rmstranamt) AS [TranSum],
SUM(rf10.rmstranamt10) AS [10Sum],
SUM(rf10.rmstranamt10) - SUM(rf.rmstranamt) AS [Balance],
cb.CurrentBalance
FROM RMASTER rm
Rules should be:
If SUM(rf.rmstranamt) is negative
SUM(rf10.rmstranamt10) + SUM(rf.rmstranamt) AS [Balance]
If SUM(rf.rmstranamt) is positive
SUM(rf10.rmstranamt10) - SUM(rf.rmstranamt) AS [Balance]
instead of how I am just subtractive everything below no matter if SUM(rf.rmstranamt) which is not right because I'll produce false positives
SELECT rm.rmsacctnum AS [Rms Acct Num],
SUM(rf.rmstranamt) AS [TranSum],
SUM(rf10.rmstranamt10) AS [10Sum],
SUM(rf10.rmstranamt10) - SUM(rf.rmstranamt) AS [Balance],
cb.CurrentBalance
FROM RMASTER rm