【发布时间】: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 partition 和 condition 当 count 是 > 然后 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
【问题讨论】: