Teradata-案例-分区

时间:2018-07-05 12:19:19

标签: case teradata partition

i具有以下查询,该查询为每个party_id带来所有与business_party_id相关的信息,每个BP的每月累积值以及该值的排名。有一个特殊的business_party_id = 200,当给定的party_id具有多个相关的business_party,并且business_party_在200时排名为1时,则不应将其视为,该party_id的排名2应该视为被视为等级1并移动200排名2。

我该怎么做?

这是我的查询

select party_id,
business_party_id, 
monthly_accum_event_amt,
Row_number() OVER (PARTITION BY  party_id ORDER BY  monthly_accum_event_amt  desc) orden

from (
    select * from P_DMT_VIEWS.BUSINESS_AGREEMENT_PAYROLL
    where LAST_DAY( payroll_dt) = '2018-05-31'
    and not business_payrroll_concept_val  in ('SUE004','SUE005','SUE00A')
    and monthly_event_qty<>0
    QUALIFY Row_number() OVER (PARTITION BY  business_party_id,party_id ORDER BY   monthly_event_qty desc  ) =1) a

0 个答案:

没有答案