PCP

1, What is PCP?
Prior Comparable Period
2, Why needs PCP?
This is to compare the value with history value.
3, How to derive the PCP value?
The simple module is:
SELECT
COALESCE(CURR.REPORT_DATE,ADD_MONTHS(PCP.REPORT_DATE, 1)) AS REPORT_DATE
,COALESCE(CURR.D1 , PCP.D1 ) AS D1 –This is dimensions
,COALESCE(CURR.D2 , PCP.D2 ) AS D2
,CURR.M1 –This is measures
,PCP.M1 AS PCP_M1
FROM PCP_TEST CURR
FULL JOIN PCP_TEST PCP
ON ADD_MONTHS(CURR.REPORT_DATE, -1) = PCP.REPORT_DATE
AND COALESCE (CURR.D1,’N/A’) = COALESCE (PCP.D1, ‘N/A’)
AND COALESCE (CURR.D2,’N/A’) = COALESCE (PCP.D2, ‘N/A’)
;
4, How to handle NULL values?

  COALESCE (CURR.D2,’N/A’) could be used in the join condition

5, When calculating for PCP values, the granularity of the table should be the combination of all the dimensions

6, How many rows before the PCP and after the PCP?

7, How to process NULL value if no data after PCP join

 

转载于:https://www.cnblogs.com/davablog/p/6667709.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值