If I have incoming values of
rmstranamt rmstrancde
50.00 51
50.00 51
50.00 51
50.00 51
50.00 51
50.00 51
50.00 51
-50.00 51
135 43
I should be getting -165 for rmstranamt in the end, not -265 which I'm getting now. Somewhere it's skipping 100
SELECT RMSFILENUM,
RMSTRANCDE,
SUM(
CASE WHEN rmstrancde IN ('50','51','52','53') AND rmstranamt < 0 THEN
rmstranamt
WHEN rmstrancde IN ('50','51','52','53') AND rmstranamt >= 0 THEN
-ABS(rmstranamt)
WHEN rmstrancde IN ('55','56','57','58') THEN
ABS(rmstranamt)
WHEN rmstrancde NOT IN ('50','51','52','53','55','56','57','58') THEN
rmstranamt
ELSE
rmstranamt
END) As rmstranamt
FROM RFINANL
WHERE RMSTRANCDE <> '10'
GROUP BY RMSFILENUM, RMSTRANCDE
rmstranamt rmstrancde
50.00 51
50.00 51
50.00 51
50.00 51
50.00 51
50.00 51
50.00 51
-50.00 51
135 43
I should be getting -165 for rmstranamt in the end, not -265 which I'm getting now. Somewhere it's skipping 100
SELECT RMSFILENUM,
RMSTRANCDE,
SUM(
CASE WHEN rmstrancde IN ('50','51','52','53') AND rmstranamt < 0 THEN
rmstranamt
WHEN rmstrancde IN ('50','51','52','53') AND rmstranamt >= 0 THEN
-ABS(rmstranamt)
WHEN rmstrancde IN ('55','56','57','58') THEN
ABS(rmstranamt)
WHEN rmstrancde NOT IN ('50','51','52','53','55','56','57','58') THEN
rmstranamt
ELSE
rmstranamt
END) As rmstranamt
FROM RFINANL
WHERE RMSTRANCDE <> '10'
GROUP BY RMSFILENUM, RMSTRANCDE