Vous devez mettre votre PS*
et REASON TEXT
où utiliser OR
conditions entre parenthèses comme ceci :
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 = '' )
N'oubliez pas que AND
l'opérateur a priorité sur OR
et lors de la combinaison de ces conditions, il est important d'utiliser des parenthèses afin que la base de données sache dans quel ordre évaluer chaque condition.
Requête complète
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 = '' )