这个代码有什么问题:
select
ACCPMF_MDANT , ACCPMF_ACPID as " Entity ID "
from ACCPMF
where ACCPMF_BERMO = ' 202012 '
case
when ACCPMF_ASOLP = ' N ' then ' 1 '
else ' 3 '
end as " Legal proceeding status "
from ACCPMF
where ACCPMF_BERMO = ' 202012 '
我有以下错误:
关键字"case"附近的语法不正确。
您已经将以case开头的列定义放在from和where之后
尝试
select
ACCPMF_MDANT ,
ACCPMF_ACPID as " Entity ID " ,
case
when ACCPMF_ASOLP = ' N ' then ' 1 '
else ' 3 '
end as " Legal proceeding status
from
ACCPMF
where
ACCPMF_BERMO = ' 202012 ';
根据您的查询,我猜ACCPMF_ASOLP也是表中的一个字段。您的错误是WHERE子句应该位于要获取的所选列/大小写指令之后;所以第一个FROM+WHERE必须在末尾:
select
ACCPMF_MDANT , ACCPMF_ACPID as " Entity ID ",
case
when ACCPMF_ASOLP = ' N ' then ' 1 '
else ' 3 '
end as " Legal proceeding status "
from ACCPMF
where ACCPMF_BERMO = ' 202012 '
注意,我忽略了这样一个事实,即您将字符串值与"x"而不是"1"(没有空格(进行比较,我假设"N"、"1"。。。你真的需要吗