Reputation: 51
I found out about a bug in my application, where the sql statement isn't displaying the correct result. I wan't every transaction from a table that gone from OR to an specific iban:
SELECT *
FROM BANKING.TRANSTAB
WHERE ABSENDER = 'DE71419330598239161300'
OR EMPF = 'DE71419330598239161300'
AND
TIME BETWEEN TO_DATE('2018-10','YYYY-MM')
AND TO_DATE('2018-12','YYYY-MM');
------+---------+---------+---------+---------+---------+---------+---------+---------+---
ROW_ID ABSENDER EMPF SUMME ZWECK
------+---------+---------+---------+---------+---------+---------+---------+---------+---
98 DE71419330598239161300 DE38820942858809256538 10.45 test
99 DE71419330598239161300 DE38820942858809256538 23.42 test
102 DE71419330598239161300 DE38820942858809256538 12.00 123
103 DE71419330598239161300 DE38820942858809256538 12.00 12
104 DE71419330598239161300 DE38820942858809256538 12.00 123
105 DE71419330598239161300 DE38820942858809256538 123.00 123
It is currently just displaying transactions that came from the selected iban altough the truth is that there are also transactions incoming:
106 DE38820942858809256538 DE71419330598239161300 1.00 spufitest
107 DE38820942858809256538 DE71419330598239161300 1.00 Spufitest
108 DE38820942858809256538 DE71419330598239161300 1.00 spufgitest
Upvotes: 0
Views: 40
Reputation: 1484
If you use OR you need to use inside bracket all OR conditions.
SELECT * FROM BANKING.TRANSTAB
WHERE (ABSENDER = 'DE71419330598239161300'
OR EMPF = 'DE71419330598239161300')
AND
TIME BETWEEN TO_DATE('2018-10','YYYY-MM')
AND TO_DATE('2018-12','YYYY-MM');
Upvotes: 1