Hi all!
Ive created this code to read in data from several tables but i have a problem with SUM. With this code im trying to add together all the null values that have the most recent date but all the SUM commandi have does is multiply the number by 3 :x
SELECT A.REFNO, MAX(B.AMT), C.STATUS, C.ENDD, C.PAMT, SUM(C.PAMT)
FROM BASIC A
LEFT JOIN TableB B ON B.REFNO = PD.REFNO
AND A.BGROUP = B.BGROUP
LEFT JOIN TableC ON A.REFNO = C.REFNO
AND A.BGROUP = PH1.BGROUP
LEFT JOIN TableC C ON B.REFNO = PS1.REFNO
AND A.BGROUP = C.BGROUP
WHERE A.REFNO = 'A170580' AND C.ENDD IS NULL
GROUP BY A.REFNO, C.STATUS, C.ENDD, C.PAMT
This is the output i get, instead of adding together 961.8 and 1274.52, it just multiplys them :(
NULL - 961.8 - 2885.4
NULL - 1274.52 - 3823.56
All help appreciated