Heres my statement:
SELECT A.AccountID,
A.LastName,
(SELECT SUM(InvCurrency) FROM B
WHERE B.BillingPeriodStart Between '2012-01-01 00:00:00.000' AND '2012-12-31 23:59:59.000' AND
A.AccountID = B.AccountID AND
StatusID = 1 AND
(ServiceCode=13 OR ServiceCode=14) AND
(ServiceCode=15 OR ServiceCode=16) AND
(ServiceCode=17 OR ServiceCode=18) AND
(ServiceCode=19 OR ServiceCode=20) AND
(ServiceCode=21 OR ServiceCode=26) )
AS 'Paid'
FROM A
order by LastName
Now, to clear some things up:
1. StatusID =1 if that customer has paid that bill, it equals 0 if he/she hasnt.
2. I only want the total amount for each person for the year 2012.
Problem:
Everything that I want pops up, only the Paid column is showing up as null and I do not know why:(, hopefully its something small. Any help is much appreciated.