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()
)
 
Back
Top