同比:
SELECT DISTINCT
B.dateM,B.dateY,B.Total,B.Total+B.Total*AVG( B.per ) OVER ( PARTITION BY B.dateM ) as predictionTotal
, AVG( B.per ) OVER ( PARTITION BY B.dateM ) AS [AvgPer]
,MAX( B.per ) OVER ( PARTITION BY B.dateM ) AS [MaxPer]
,Min( B.per ) OVER ( PARTITION BY B.dateM ) AS [MinPer] from
(SELECT A.dateM,A.dateY
,A.[Total] - A.[PreviousTotal] as GrowthTotal,(A.[Total] - A.[PreviousTotal])/A.[PreviousTotal] as per,A.[Total]
, A.[Month]
FROM
(
select s.dateM,dateY,COUNT(*) OVER ( PARTITION BY s.dateM ) AS [Month],s.[Total] AS [Total]
, LAG( s.[Total] ) OVER ( PARTITION BY s.dateM ORDER BY s.dateY ) AS [PreviousTotal]
from (SELECT datepart(mm,[month]) as dateM, datepart(yyyy,[month]) as dateY,sum([Total]) Tot
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ji-chu/82783.html