环比同比
Posted .x->y=z
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了环比同比相关的知识,希望对你有一定的参考价值。
1 SELECT 2 TEMP.*, 3 NVL(round(((TEMP.CollectionAmount + TEMP.StayCollectionAmount) / lag(TEMP.CollectionAmount + TEMP.StayCollectionAmount) over(order by TEMP.MonthID)) * 100, 2), ‘0‘) || ‘%‘ "环比", 4 NVL(round(((TEMP.CollectionAmount + TEMP.StayCollectionAmount) / lag(TEMP.CollectionAmount + TEMP.StayCollectionAmount) over(partition by SUBSTR(to_char(TEMP.MonthID), 5, 2) ORDER BY TEMP.MonthID)) * 100, 2), ‘0‘) || ‘%‘ "同比" 5 FROM 6 (SELECT 7 * 8 FROM 9 tds_agent_org_revcoll_mon T 10 WHERE 11 T.companyId = -1 12 AND T.MonthID >= ‘201601‘ 13 AND T.MonthID <= ‘201707‘) TEMP
参考lag和lead函数。
^_^
以上是关于环比同比的主要内容,如果未能解决你的问题,请参考以下文章