Anda harus memasukkan PS*
dan REASON TEXT
di mana menggunakan OR
kondisi ke dalam tanda kurung seperti ini:
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 = '' )
Ingat bahwa AND
operator didahulukan daripada OR
dan saat menggabungkan kondisi ini, penting untuk menggunakan tanda kurung agar database mengetahui urutan evaluasi setiap kondisi.
Kueri lengkap
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 = '' )