【问题标题】:case expression with count and condition of count is greater then具有计数和计数条件的 case 表达式大于
【发布时间】:2019-07-29 13:58:46
【问题描述】:

我有下表

表 A

PK    status_cd  id    grp  grp_rnk_asc  grp_rnk_desc   action_dt
154    new       10    1     1             4               11/6/2019
154    pending   10    1     2             3               11/7/2019
154    pending   10    1     3             2               11/8/2019
154    approved  10    1     4             1               11/9/2019

我想……

Count partitionconditioncount> 然后 1 然后“通过”

然后可以将额外的when 添加到case expression

例如:

标准示例

select 
Count when status_cd not in ('new','approved') 
over (partition by id,grp order by action_dt) if that count > 1 then 'pass'

--also be able to add new conditions here...
from A
--no where clause

【问题讨论】:

    标签: sql oracle case


    【解决方案1】:

    我想你想要:

    select (case when sum(case when tatus_cd not in ('new',' approved') then 1 else 0 end) over (partition by id, grp) > 1
                 then 'pass'
            end)
    from A
    

    【讨论】:

      猜你喜欢
      • 2021-01-15
      • 1970-01-01
      • 2021-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 2019-06-09
      • 2016-05-24
      相关资源
      最近更新 更多