over PARTITION BY查询抛出错误

时间:2016-11-02 18:17:22

标签: teradata

此查询应该适用于恕我直言:

SELECT        
    Year                             
    ,Month 
    ,SUM(SomeFactMeasure) OVER (PARTITION BY Year BY Month) AS BigSum
    ,SUM(SomeFactMeasure) AS SmallSum 
FROM SomeTable
GROUP BY 1, 2;

不幸的是,我得到了:

SELECTED NON-AGGREGATE VALUES MUST BE PART OF THE ASSOCIATED GROUP

1 个答案:

答案 0 :(得分:1)

OLAP函数在聚合之后计算,没有更多细节SomeFactMeasure要在组和中求和。

您需要在聚合结果上应用功能,标准SQL兼容SUM(SUM(SomeFactMeasure)) OVER或Teradata重用别名SUM(SmallSum) OVER