recouptax_pay为一个计算字段,pay是应领工资 如果pay*.087-1600小于等于0的recouptax_pay=0,
否则recouptax_pay=pay*0.87-1600
[recouptax_pay] as (iif((pay*0.87-1600)>0,pay*0.87-1600,0))
提示错误:Msg 170, Level 15, State 1, Procedure pr_paycount, Line 44
行 44: '>' 附近的語法不正確。看了sql server 2000的帮助
IIf(«Logical Expression», «Numeric Expression1», «Numeric Expression2»)如果 «Logical Expression» 得出 TRUE,這個函數傳回 «Numeric Expression1»;否則傳回 «Numeric Expression2»。

解决方案 »

  1.   

    IIf(«Logical Expression», «Numeric Expression1», «Numeric Expression2»)如果 «Logical Expression» 得出 TRUE,這個函數傳回 «Numeric Expression1»;否則傳回 «Numeric Expression2»。
      

  2.   

    iif()是Access中的函数,SQL Server中用case when。如:case when 字段名=100 then 1 else 0 end
      

  3.   

    [recouptax_pay] as (case when (pay*0.87-1600)>0 then pay*0.87-1600 else 0 end))
      

  4.   

    [recouptax_pay] as (case when (pay*0.87-1600)>0 then pay*0.87-1600 else 0 end))