我有一个有趣的问题。我将编写一个标量值函数。其中一个参数不在表格列中。我必须在 where 子句中使用这个参数 (@ImpUrgPri)。至于那个参数,会有一个条件,表中存在一个列。你能帮我解决这个问题吗?
DECLARE @ImpUrgPri NVARCHAR(3)
SET @ImpUrgPri = 'URG'
DECLARE @Enum INT
SET @Enum = 0
select COUNT(*)
from zODYA_vwCallReq_AllData
where ActiveFlag = 1
AND
(CASE WHEN (@ImpUrgPri = 'PRI') THEN Priority_Enum == @Enum
WHEN (@ImpUrgPri = 'URG') THEN Urgency_Enum == @Enum
WHEN (@ImpUrgPri = 'IMP') THEN Impact_Enum == @Enum END)
group by
(CASE WHEN (@ImpUrgPri = 'PRI') THEN Priority_Enum
WHEN (@ImpUrgPri = 'URG') THEN Urgency_Enum
WHEN (@ImpUrgPri = 'IMP') THEN Impact_Enum END)