案例陈述/职能

时间:2016-06-01 13:15:41

标签: sql oracle oracle11g case where-clause

我需要Oracle v11中CASE语句的帮助。我的公司使用TRAX Maintenance作为其软件,并使用QuickPrint构建“构建您自己的报告”。我正在尝试做一个小的CASE语句/函数,但只得到错误消息。任何人都可以帮忙吗?下面是完整的代码(非常简单),结果将返回1列,这是结果。

SELECT "ENGINEERING_ORDER"."EO" AS "EO",
       "ENGINEERING_ORDER"."EO_DESCRIPTION" AS "EO_DESCRIPTION",
       CASE,
       WHEN "ENGINEERING_ORDER"."SCHEDULE_HOURS"=0
   AND "ENGINEERING_ORDER"."SCHEDULE_CYCLES"=0 THEN "ENGINEERING_ORDER"."SCHEDULE_DAYS",
       WHEN "ENGINEERING_ORDER"."SCHEDULE_HOURS"=0
   AND "ENGINEERING_ORDER"."SCHEDULE_DAYS"=0 THEN "ENGINEERING_ORDER"."SCHEDULE_CYCLES",
       ELSE "ENGINEERING_ORDER"."SCHEDULE_HOURS",
       END
  FROM ENGINEERING_ORDER

我得到的错误是:

  

ORA-00923:未找到FROM关键字

     

ORA-00936:缺少表达

和其他人取决于您可以执行的其他方式CASE

1 个答案:

答案 0 :(得分:1)

删除,case之间的所有逗号(end),它们不应该在那里:

SELECT "ENGINEERING_ORDER"."EO" AS "EO",
       "ENGINEERING_ORDER"."EO_DESCRIPTION" AS "EO_DESCRIPTION",
       CASE
         WHEN "ENGINEERING_ORDER"."SCHEDULE_HOURS"=0
          AND "ENGINEERING_ORDER"."SCHEDULE_CYCLES"=0
         THEN "ENGINEERING_ORDER"."SCHEDULE_DAYS"
         WHEN "ENGINEERING_ORDER"."SCHEDULE_HOURS"=0
          AND "ENGINEERING_ORDER"."SCHEDULE_DAYS"=0 
         THEN "ENGINEERING_ORDER"."SCHEDULE_CYCLES"
         ELSE "ENGINEERING_ORDER"."SCHEDULE_HOURS"
       END
  FROM ENGINEERING_ORDER