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!
 
M

[MVP] S.Clark

Does the PaymentsKey columns have an unique index?

What's wrong with the query now? Too slow?

--
Steve Clark, Access MVP
FMS, Inc.
Call us for all of your Access Development Needs!
1-888-220-6234
(e-mail address removed)
www.fmsinc.com/consulting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top