简体   繁体   English

带有sysdate的案例声明

[英]Case Statement with sysdate

Good day all. 大家好。 I have an Excel workbook that has an ODBC connection to an oracle database. 我有一个Excel工作簿,该工作簿具有到oracle数据库的ODBC连接。 I have a query built into the command text to pull down some data. 我在命令文本中内置了一个查询,以提取一些数据。 I am rather new at doing this stuff and I recently learned of the existence of "case" statements, but I have no clue as to what I am doing. 我在做这些事情时还比较陌生,最近我了解到“ case”语句的存在,但是我不知道自己在做什么。

I am looking for the proper state to produce the following result 我正在寻找适当的状态以产生以下结果

If Table.Datefield is less or equal to System Date - 14 days then show "New" If Table.Datefield is greater than System Date - 14 days then show "Waiting Approval". 如果Table.Datefield小于或等于系统日期-14天,则显示“新建”;如果Table.Datefield大于系统日期-14天,则显示“等待批准”。

I have tried 我努力了

    case 
when "Table"."APPROVEDON" > sysdate - 14 then 'New'
when "Table"."APPROVEDON" < sysdate - 14 then 'Waiting Approval'
else 'N/A'
end as "Status"

However, I get a missing expression error. 但是,我收到一个缺少表达的错误。

As I said I am very new to this. 正如我所说的,我对此很陌生。 I tried some searching, but I am unsure of what to really search for. 我尝试了一些搜索,但是不确定真正要搜索什么。

As it is the wrong syntax it was throwing an error. 由于语法错误,因此引发了错误。 Try this. 尝试这个。

CASE //columnName//
when //tblname.columnname// > //columnname//- 14 then 'New'
when //tblname.columnname// < //columnname// - 14 then 'Waiting Approval'
else 'N/A'
end as "Status"

(you have to tell the query statement on which column you want to perform the case operation). (您必须告诉查询语句要在哪个列上执行案例操作)。 Hope it helps !! 希望能帮助到你 !!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM