Sie müssen Ihren PS* eingeben und REASON TEXT wobei OR verwendet wird Bedingungen in Klammern wie folgt:
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 = '' )
Denken Sie daran, dass AND Operator hat Vorrang vor OR und beim Kombinieren dieser Bedingungen ist es wichtig, Klammern zu verwenden, damit die Datenbank weiß, in welcher Reihenfolge jede Bedingung ausgewertet wird.
Vollständige Abfrage
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 = '' )