G
GLW
I have a table with the fields AcctNum, TransactType, TransactDate. I need
to query for TransactType BUY where there has not been a TransactType SELL in
the same AcctNum for the 90 preceding the TransactDate. I can't think of a
way to make a sub-query look at AcctNumber and TransactDate so I tried
linking the table to itself in a query like this:
SELECT [MyTable].[AcctNum], [MyTable].[TransactType],
[MyTable].[Transact].[Date]
FROM [MyTable] INNER JOIN [MyTable_1] ON [MyTable].[AcctNum] =
[MyTable_1].[AcctNum]
WHERE ([MyTable].[TransactType] = "BUY") AND (([MyTable_1].[TransactType] =
"SELL") AND ([MyTable_1].[TransactDate] Not Between
([MyTable].[TransactDate]) - 90 and ([MyTable].[TransactDate])))
But, of course, I got a bunch of duplicates and when I try to do SELECT
DISTINCT the connection always times out. Am I at all on the right track?
Can anyone suggest something better? Thanks.
to query for TransactType BUY where there has not been a TransactType SELL in
the same AcctNum for the 90 preceding the TransactDate. I can't think of a
way to make a sub-query look at AcctNumber and TransactDate so I tried
linking the table to itself in a query like this:
SELECT [MyTable].[AcctNum], [MyTable].[TransactType],
[MyTable].[Transact].[Date]
FROM [MyTable] INNER JOIN [MyTable_1] ON [MyTable].[AcctNum] =
[MyTable_1].[AcctNum]
WHERE ([MyTable].[TransactType] = "BUY") AND (([MyTable_1].[TransactType] =
"SELL") AND ([MyTable_1].[TransactDate] Not Between
([MyTable].[TransactDate]) - 90 and ([MyTable].[TransactDate])))
But, of course, I got a bunch of duplicates and when I try to do SELECT
DISTINCT the connection always times out. Am I at all on the right track?
Can anyone suggest something better? Thanks.