Tienes que poner tu PS*
y REASON TEXT
donde usando OR
condiciones en paréntesis como este:
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 = '' )
Recuerda que AND
el operador tiene prioridad sobre OR
y al combinar estas condiciones, es importante usar paréntesis para que la base de datos sepa en qué orden evaluar cada condición.
Consulta 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 = '' )