Is this as efficient as it could be?

G

Gary B

Can please someone help me write this Query:

tblServices:
ServicesKey
ChargesKey
ServiceAmount

tblPayments:
PaymentsKey
PaymentsDate
PaymentsAmount

tblApplies:
PaymentsKey
ServicesKey
ApplyAmount

I want to return payments that are not fully applied as follows:

SELECT tblPayments.PaymentsKey, PaymentsAmount, Sum(tblApplies.ApplyAmount)
FROM tblPayments LEFT JOIN tblApplies on tblPayments.PaymentsKey =
tblApplies.PaymentsKey
GROUP BY tblPayments.PaymentsKey
HAVING ((PaymentsAmount - Sum(tblApplies.ApplyAmount)) >=.01)

Is this as efficient as it could be?

THANK YOU!
 
Top