$ 0 0 Simply write your condition into the RANK: qualify rank() over (partition by CAD.CUST_ACCT_KEY or whatever you need order by case WHEN RCVR_TYPE_DESC = 'AAA' THEN 1 WHEN RCVR_TYPE_DESC = 'BBB' THEN 2 WHEN RCVR_TYPE_DESC = 'CCC' THEN 3 WHEN RCVR_TYPE_DESC = 'DDD' THEN 4 end ) = 1 Dieter
Simply write your condition into the RANK:
Dieter