【问题标题】:multiple conditions in oracle case with one :PAR一个 :PAR 的 oracle 案例中的多个条件
【发布时间】:2023-02-05 19:01:02
【问题描述】:

我有一个更复杂的查询,但我会举一个简单的例子。在 SSRS 中相同的输入但需要不同的输出:

select * from myTable where
case
when :PAR1 = 'hour' then myTable.hour = :PAR1
when :PAR1 = 'Mounth' then myTable.Mounth = :PAR1
end

如何制作?

我试着

case length(:PAR1)
when 18 then hour: = PAR1
..

总是出错。。

【问题讨论】:

    标签: sql oracle reporting-services


    【解决方案1】:

    这里不需要 CASE 表达式:

    SELECT *
    FROM myTable
    WHERE (:PAR1 = 'hour' AND hour = :PAR1) OR
          (:PAR1 = 'Mounth' AND Mounth = :PAR1);
    

    【讨论】:

      【解决方案2】:

      您发布的代码对我来说没有意义;你是当然使用:PAR1到处?我会期待这样的事情

      select *
      from mytable
      where (:PAR1 = 'hour'   and hour   = :PAR2) 
         or (:PAR1 = 'Mounth' and mounth = :PAR2)
                                          -------
                              maybe not :PAR2, but 
                              certainly not :PAR1
      

      另外,当你处理小时, 什么是?不应该是

      【讨论】:

        猜你喜欢
        • 2017-03-06
        • 1970-01-01
        • 2021-11-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多