I have the below table
Table 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'
Then be able to add additional when
to the case expression
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.