Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Case表达式中的Case表达式_Sql_Sql Server_Case - Fatal编程技术网

Sql Case表达式中的Case表达式

Sql Case表达式中的Case表达式,sql,sql-server,case,Sql,Sql Server,Case,我正在使用LIMS数据库软件,并试图为我们的分析师简化事情 最初,我有一个直接的案例陈述,它对我们使用的每个“测试”都非常有效 案例 当([干肥料].[磷ICP(

我正在使用LIMS数据库软件,并试图为我们的分析师简化事情

最初,我有一个直接的案例陈述,它对我们使用的每个“测试”都非常有效

案例
当([干肥料].[磷ICP(<6.99瓜尔胶)].[磷]<([干肥料].[磷保证].[磷保证]-0.67))
然后-1或者0
终止
另一个

CASE
    WHEN ([Dry Fertilizer].[Phosphorus ICP (10-13.99 Guar)].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.69)) THEN -1
    ELSE 0
END
案例
当([干肥料].[磷ICP(10-13.99瓜尔胶)].[磷]<([干肥料].[磷保证].[磷保证]-0.69))时,则-1
其他0
终止
其目的是查看测试结果[磷],与已知数字[保证]进行比较,然后计算并输出“-1”,如果低于该数字,则为失败或“0”并通过

现在,我没有对每个“保证”进行不同的测试,而是考虑获取所有这些数字并进行相当大的计算,但当我尝试运行计算时,我的软件只是挂起。我能做些什么来简化这段代码或使它工作?代码如下:

CASE    When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =4) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 ELSE 0 End

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =5) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =6) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =7) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.68)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =8) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.68)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =9) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.68)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =10) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.69)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =12) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.69)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =14) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.7)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =16) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.7)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =18) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.71)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =20) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.72)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =22) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.72)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =24) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.73)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =26) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.73)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =28) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.74)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =30) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.75)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =32) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.76)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =34) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.794)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =36) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.828)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =38) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.862)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =40) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.896)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =42) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.93)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =44) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.964)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =46) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.998)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =48) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-1.032)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =50) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-1.066)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =52) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-1.1)) THEN -1 ELSE 0 End 


End
当([干肥].[磷保证].[磷保证]=4)时的情况
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.67))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=5)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.67))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=6)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.67))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=7)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.68))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=8)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.68))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=9)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.68))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=10)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.69))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=12)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.69))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=14)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.7))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=16)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.7))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=18)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.71))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=20)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.72))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=22)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.72))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=24)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.73))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=26)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.73))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=28)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.74))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=30)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.75))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=32)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.76))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=34)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.794))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=36)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.828))时,则-1否则0结束
当([干肥].[磷保证].[磷保证]=38)时
当([干肥].[磷ICP].[磷]<([干肥].[磷保证].[磷保证]-0.862))时,则-1否则0结束
什么时候
CASE    When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =4) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 ELSE 0 End

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =5) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =6) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =7) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.68)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =8) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.68)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =9) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.68)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =10) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.69)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =12) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.69)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =14) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.7)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =16) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.7)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =18) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.71)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =20) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.72)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =22) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.72)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =24) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.73)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =26) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.73)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =28) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.74)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =30) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.75)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =32) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.76)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =34) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.794)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =36) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.828)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =38) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.862)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =40) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.896)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =42) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.93)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =44) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.964)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =46) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.998)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =48) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-1.032)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =50) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-1.066)) THEN -1 ELSE 0 End 

When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =52) Then
    Case When ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-1.1)) THEN -1 ELSE 0 End 


End
 SELECT CASE When ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee] =4) AND ([Dry Fertilizer].[Phosphorus ICP].[Phosphorus] < ([Dry Fertilizer].[Phosphorus Guarantee].[Phosphorus Guarantee]-0.67)) THEN -1 
 WHEN
 WHEN
 WHEN ETC
 ELSE 0 END AS [YOURCOL]