[英]case expression with count and condition of count is greater then
I have the below table我有下表
Table A表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
I want to...我想要...
Count
partition
with condition
and when that count
is >
then 1 then 'pass'使用condition
Count
partition
,当该count
>
等于 1 时,则“通过”
Then be able to add additional when
to the case expression
然后能够在case expression
添加额外的when
For example:例如:
Sample of criteria标准样本
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
I think you want:我想你想要:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.