我有一个标量函数返回位,我想以下面的方式使用它:
SELECT @SalesPlanExists =
IIF(adm.SalesPlanExists(@Year, @Month, @CountryID, 'Country') OR adm.SalesPlanExists(@Year, @Month, @CountryID, 'Region') = 0, 0, 1)
SELECT
a.KPI_Application_Count
,a.KPI_Application_Count_Plan
,a.KPI_Application_Count_Performance
,IIF(@SalesPlanExists = 0, 1, b.[Status]) AS KPI_Resolved_Application_Count_Status
FROM
#Calcul a
LEFT JOIN kpi.Indicator b
ON a.KPI_Application_Count_Performance BETWEEN b.RangeMin AND b.RangeMax AND b.NameID = 10
返回
在上下文中指定的非布尔类型的表达式 条件是预期的,接近' OR'。
帮助将不胜感激。
答案 0 :(得分:0)
这行不应包含' = 0'像这样:
SELECT @SalesPlanExists =
IIF(adm.SalesPlanExists(@Year, @Month, @CountryID, 'Country') = 0
OR adm.SalesPlanExists(@Year, @Month, @CountryID, 'Region') = 0, 0, 1)