campkev,
I don't have much experience with Microsoft SQL Server, I use Oracle. However this is how I would approch it in Oracle. The syntax may be different in SQL Server but the principal will be the same.
select count(1)
from transfer t, account a1, account a2,
where t.toaccount = a1.accountid
and t.fromaccount = a2.accountid
and a1.bank = a2.bank
If there are appropiate indexes on the tables in question this should be fast.
By the way, using multiple 'in' statements like you posted is very expensive. Using joins is prefered.
Kate
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
Offline 71 posts
since Jun 2005