我有一个“特殊情况”需要在sql脚本中考虑。这是我到目前为止所拥有的,我“认为”它有效,但看起来很乱。它sproc假设有一个@empStatus参数。如果员工的@empStatus=2我想用Statusof1或退回所有员工的2。
select *
from Employees
where Title='Associate' and Status=@empStatus and Department='Sales'
OR (@empStatus=2 and (Status=@empStatus or Status=1) and Title='Associate' and Department='Sales')