zoukankan      html  css  js  c++  java
  • 环比同比

     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函数。

    ^_^

  • 相关阅读:
    抽象类
    类初始化
    final关键字
    super关键字
    继承
    常用类

    封装
    方法重载
    031:Cetus sharding
  • 原文地址:https://www.cnblogs.com/gotodsp/p/7657284.html
Copyright © 2011-2022 走看看