我正在尝试使用SQL Decode语句来解码(D.code ,2,'Resident',else,'Business')描述,有没有一种方法可以识别解码语句中的其他所有内容?
发布于 2013-08-14 00:12:33
是的,有:
decode ( <condition>, <test expr #1>, <result #1>, ..., <test expr #n>, <result #n>, <fallback result>);但是,在标准sql中,您将使用
case <condition>
when <test expr #1> then <result #1>
...
when <test expr #n> then <result #n>
else <fallback result>
end发布于 2019-06-06 02:48:17
除了在DECODE函数中没有使用'else‘之外,你的基本语法是正确的。在圆括号中,首先是要解码的内容,然后是代码/描述对,最后是可选的默认值(else)。
下面是我使用的一个示例:
DECODE(status,'A','Approved','D','Declined','I','Counter Offer','Other')祝好运,
马文
https://stackoverflow.com/questions/18213972
复制相似问题