SQL Oracle 中多个条件的 Case 语句

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40230632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 04:57:50  来源:igfitidea点击:

Case Statement on Multiple conditions in Oracle

sqloraclecase

提问by Annie Jeba

CASE test
WHEN  NULL and  SUBSTR(('99999999' - Tst_Date),1,4) > 2009 THEN 'Medi'                     
WHEN   NULL and SUBSTR(('99999999' - Tst_Date),1,4) < 2009 THEN 'hills'
ELSE test
END AS "Phy"

Am i missing something in the above case statement? I keep on getting 00905. 00000 - "missing keyword" error?

我在上面的案例陈述中遗漏了什么吗?我不断收到 00905. 00000 - “缺少关键字”错误?

回答by Tim Biegeleisen

Your syntax is a little bit off. Use this:

你的语法有点不对。用这个:

CASE WHEN test IS NULL AND SUBSTR(('99999999' - Tst_Date),1,4) > 2009 THEN 'Medi'
     WHEN test IS NULL AND SUBSTR(('99999999' - Tst_Date),1,4) < 2009 THEN 'hills'
     ELSE test
END AS "Phy"