I have a table balances with the following columns:
bank | account | date | amount
I also have a table accounts that has bank and account as its composite primary key.
I want to do a query like the following pseudocode:
select date, sum(amount) as amount from balances where bank and account in (list of bank and account pairs) group by date
The list of bank-account pairs is supplied by the client. How do I do this? Create a temp table and join on it?
I’m using Sybase
If bank account pairs is known in you app you just write:
If list of bank account pairs is a subquery, then write something like this: