2

如果条件正确,那么我希望将其标记为“暂停审核......”,如果它们不正确,则将其留空或由 t.fstrTaskSource + ' TYP ' + t填充.fstrType 语句(这部分已经有效)

SELECT  t.flngKey AS flngTaskKey,
t.fstrAccountType,
t.fstrTaskSource,
CASE    t.fstrCategory 
    WHEN    '' THEN '' 
    ELSE    t.fstrTaskSource + '_CAT_' + t.fstrCategory 
    END AS fstrCategory,
CASE    t.fstrType 
    WHEN    '' THEN '' 
    WHEN    (wd.fstrWorkType    = 'SUSIN1' -- I am getting a syntax error here on the = sign --
        AND wd.fstrOwner        =  ' ' 
        AND wd.flngworkkey      =  wr.flngworkkey 
        AND wr.fstrAccountType  <> '007' 
        AND wr.fblnOpen         =  1 
        AND EXISTS  
            (SELECT 1 
            FROM    tblIndicator i
            WHERE   i.fstrIndicator   = 'EIWTCH' 
            AND i.flngVer         = 0 
            AND i.flngAccountKey  = wd.flngAccountKey)) -- I am also getting an error here on the ) sign --
    THEN 'Suspended for Audit Indicator - EIC Watch For'
    ELSE    t.fstrTaskSource + '_TYP_' + t.fstrType 
    END AS fstrType
4

2 回答 2

3

你的第二个Case ExpressionSimple Case和的混合Searched Case

IE

CASE    t.fstrType 
  WHEN    '' THEN '' 
  WHEN    (wd.fstrWorkType    = 'SUSIN1' 

将其更改为Searched Case表达式:

CASE WHEN t.fstrType = '' THEN ''
     WHEN (wd.fstrWorkType    = 'SUSIN1'  ...

案例表达式的两种格式是:

--Simple CASE expression: 
CASE input_expression 
     WHEN when_expression THEN result_expression [ ...n ] 
     [ ELSE else_result_expression ] 
END 

--Searched CASE expression:
CASE
     WHEN Boolean_expression THEN result_expression [ ...n ] 
     [ ELSE else_result_expression ] 
END
于 2013-11-06T17:42:46.193 回答
0

您正在尝试同时使用 CASE 的两种语法

首先:

case expression
    when "val1" then ..
    when "val2" then ..
end

第二:

case
    when column = "val1" then ..
    when column2 = "val2" then ..
end

所以,在你的第二个中使用它CASE

CASE
    WHEN t.fstrType = '' THEN ''
    WHEN (wd.fstrWorkType = 'SUSIN1' ...
于 2013-11-06T17:45:08.820 回答