【发布时间】:2019-10-04 14:43:15
【问题描述】:
谁能告诉我“end = 'Y')”中最后一个'Y'有什么用
( case
when a = 'STAGE PAYMENT' then
'Y'
when b not IN ('To be Received', 'Received') then
'N'
when c != (d - NVL(e, 0) - NVL(f, 0) - NVL(g, 0)) then
'Y'
when NVL(h, 0) + NVL(i, 0) + NVL(j, 0) <> 0 then
case
when c != k then
'Y'
when (-l != NVL(e, 0) + NVL(f, 0) + NVL(g, 0) + NVL(m, 0)) then
'Y'
else 'N'
end
else 'N'
end = 'Y')
还有,有什么办法可以优化吗?
谢谢!
【问题讨论】:
-
这个case语句的上下文是什么?看起来它可能是
where子句的一部分? -
是的,它是选择查询的一部分,它就在 where 子句之后。
-
看起来声明
end = 'Y')应该以end) = 'Y'结尾 -
@BarbarosÖzhan 外括号是完全没有必要的,所以右括号在
= 'Y'之后还是之前都没有关系 -
我的意思是两种方式都可以有或没有括号,这取决于 OP 呈现的内容,我认为括号@Boneist
标签: oracle plsql nested conditional-statements case