I’m not sure I’m understanding this correctly, so I need some help
WHERE ((ISNULL(T.TransT_strBarcodeRedemp,'') <> '' AND ISNULL(T.TransT_strVoucherBarcode,'') = '')
OR TS.HOPK in ('S','T','U','V','W','X','Y') OR TickNum_strStyleCode = '|TICK|S|N|N|N|' OR TickNum_strStyleCode = '|CONC|S|N|N|T|')
and not exists(select 1 from zz_PaidVoucher PV where PV.VoucherCode = LEFT(ISNULL(TransT_strBarcodeRedemp,''),4) or PV.VoucherCode = LEFT(ISNULL(TransT_strVoucherBarcode,''),4))
From what I understand the this will split into 3 parts. One with the first “AND” in parenthesis
(ISNULL(T.TransT_strBarcodeRedemp,’’) <> ‘’ AND ISNULL(T.TransT_strVoucherBarcode,’’) = ‘’)
then to The three OR’s and then to the final not exist.
So the First parenthesis “AND” part will take place only if it finds a match, if not then the OR’s will take part and if nothing found on the OR’s then the not exists does not really do something.
If that is correct then this is a wrong script that I need to change. Can you let me know if my explanation is correct?