Query help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with the following fields: AccountNumber, TransactionType,
TransactionDate. TransactionType can be BUY or SELL. I need to query this
table to find TransactionType BUY where there has been no TransactionType
Sell for the same AccountNumber for 90 days preceding the TradeDate of the
BUY. Is there a way to make a subquery look at 2 fields in the main query?
Any other suggestions? Any ideas would be welcome. Thanks
 
select *
from table
where TransactionType='Buy' AND
AccountNumber NOT IN (
select distinct AccountNumber
from Table Table2
where TransactionType='Sell'
and TransactionDate between dateadd("d",-90,now()) and now()
)
 

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

Back
Top