如何在oracle里面的where子句中使用case语句?

时间:2016-10-20 12:25:22

标签: oracle plsql case

我正在获取PL / SQL:ORA-00905:运行以下脚本时缺少关键字错误

gems

请帮帮我

3 个答案:

答案 0 :(得分:5)

For those who land here that actually have a need for a case statement in a where clause.

 where (case
          when ass_line = '551F' then
           case
              when asl.assembly_line in ('551F', '551C', '551S') then
               1
              else
               0
           end
          else
          case
             when asl.assembly_line = ass_line then
              1
             else
             0
          end
       end) = 1

答案 1 :(得分:3)

您无法使用{ "error": { "message": "Unsupported get request. Object with ID '1015359838XXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api", "type": "GraphMethodException", "code": 100, "fbtrace_id": "DLyfwGbM8fi" } } ,必须使用case

or

答案 2 :(得分:3)

你应该使用:

where (ass_line  = '551F' and asl.assembly_line in('551F','551C','551S')) or
      (ass_line != '551F' and asl.assembly_line = ass_line)