我需要你的帮助:
我想获得金额字段的总和,它包含十进制值,但我只得到INTEGER
部分,我也需要DECIMAL
:
DECLARE @TOTAL AS DECIMAL(13,2)
SET @Total = (SELECT SUM(Amount)
FROM t_DownPmtTrans
WHERE MortgageID = @MortgageID
AND DatePaid IS NULL
AND SchedPayment IS NOT NULL)
我尝试过使用 CURSOR 但我得到了相同的结果:
OPEN dpt_cursor
SET @Total= 0.0
FETCH NEXT FROM dpt_cursor INTO @DownPmtTransID, @Amount
WHILE @@FETCH_STATUS= 0
BEGIN
PRINT @Amount
SET @Total = (@Total + @Amount)
FETCH NEXT FROM dpt_cursor
INTO @DownPmtTransID, @Amount
END
RETURN @Total* (-1)
CLOSE dpt_cursor
DEALLOCATE dpt_cursor
谢谢!!