Please support our MS SQL advertiser: Programming Forums
Views: 866 | Replies: 3
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
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
Last edited by chris-uk-lad : Jul 22nd, 2008 at 4:44 pm.
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Threaded Mode