Link to home
Start Free TrialLog in
Avatar of N M
N MFlag for Luxembourg

asked on

MS-ACCESS conditional SELECT

In MS-ACCESS I have two tables, say T1 and T2, both of them with fields T1.Customer_No, T1.AMOUNT, T1.TRADE_ID and T1.DATE1 fields and T2.Customer_No, T2.AMOUNT_1, T2.AMOUNT_2 and T2.DATE1.
I need to select all rows from T1 where :

T1.AMOUNT = ABS(T2.AMOUNT_1) *OR* T1.AMOUNT = ABS(T2.AMOUNT_2)
and additionally
T1.DATE1 = T2.DATE1

Constraint: if T2.AMOUNT_1 is null or T2.AMOUNT_2 is null, then I don't want any comparison (excluded records).

(No I can't join customer ids)
Any help appreciated.
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Give this a try for your where statement

Where T1.DATE1=T2.DATE1 and 
((T1.AMOUNT = ABS(T2.AMOUNT_1))  OR (T1.AMOUNT = ABS(T2.AMOUNT_2)))
and NOT T2.AMOUNT_1 Is Null and NOT T2.AMOUNT_2 Is Null

Open in new window

Avatar of N M

ASKER

Sorry didn't understood the comment.......
ASKER CERTIFIED SOLUTION
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N M

ASKER

Yes, worked, thank you very much !
Avatar of N M

ASKER

Accurate and fast - thank you !