Devi inserire il tuo PS*
e REASON TEXT
dove usando OR
condizioni tra parentesi come questa:
where (
REASON_TEXT = 'Parts Not available (ASC)'
or REASON_TEXT = 'Parts In Transit (Samsung)'
or REASON_TEXT = 'Parts Back Ordered (Samsung)'
)
and PS1 = 'U'
and ( PS2 = 'U' or PS2 = '' )
and ( PS3 = 'U' or PS3 = '' )
and ( PS4 = 'U' or PS4 = '' )
and ( PS5 = 'U' or PS5 = '' )
Ricorda che AND
l'operatore ha la precedenza su OR
e quando si combinano queste condizioni, è importante utilizzare le parentesi in modo che il database sappia in quale ordine valutare ciascuna condizione.
Richiesta completa
SELECT TOP 10000 [Service_order]
,[COMPANY]
,[PENDING_DAYS]
,[SERVICE_TYPE]
,[SERVICE_TYPE_TXT]
,[STATUS]
,[STATUS_TEXT]
,[REASON]
,[REASON_TEXT]
,[ASC code]
,[ASC name]
,[MODEL]
,[INOUTWTY]
,[Part_code1]
,[PS1]
,[confirmation_No1]
,[Part_code2]
,[PS2]
,[SO_NO2]
,[Part_code3]
,[PS3]
,[SO_NO3]
,[Part_code4]
,[PS4]
,[SO_NO4]
,[Part_code5]
,[PS5]
,[SO_NO5]
,[Engineer name]
FROM ['NewLP']
where (
REASON_TEXT = 'Parts Not available (ASC)'
or REASON_TEXT = 'Parts In Transit (Samsung)'
or REASON_TEXT = 'Parts Back Ordered (Samsung)'
)
and PS1 = 'U'
and ( PS2 = 'U' or PS2 = '' )
and ( PS3 = 'U' or PS3 = '' )
and ( PS4 = 'U' or PS4 = '' )
and ( PS5 = 'U' or PS5 = '' )