ฉันมีเงื่อนไขที่ซับซ้อนสองสามประการในขั้นตอนการจัดเก็บของฉัน เช่น
if @Acr != '' and @Acr != '<Select All>'
begin
delete from #temp where O_client != @Acr and O_originreason != 'RTE'
end
if @Acr = '<Select All>'
begin
delete from #temp where LEFT(O_client, 5) = 'WS80_'
AND O_client IS NULL
AND O_originreason != 'RTE'
end
if @Chnl != '' and @Chnl != '<Select All>'
begin
delete from #temp where C_Channel != @Chnl
end
และฉันต้องการกำจัดมัน และปรับใช้ใหม่ในตัวกรองชุดข้อมูลในรายงาน แต่ฉันไม่เข้าใจวิธีการสร้างเงื่อนไขที่ซับซ้อนเช่นนี้