任何人都可以在oracle分区的sum
sum
内告诉我(SUM(SUM(VAL)))
的重要性,请参阅以下代码段
SELECT NMS,
SUM(SUM(VAL)) OVER(PARTITION BY NMS), ---- SIGNIFICANCE
EMPNO,
SUM(SUM(VAL)) OVER(PARTITION BY EMPNO) ---- SIGNIFICANCE
FROM PART_TEST_PART
GROUP BY NMS, EMPNO;
答案 0 :(得分:6)
计算VAL
每NMS
(第一个)和EMPNO
(第二个)的总和。
首先评估组+ SUM(VAL),然后分析计算该结果。
e.g。如果您在
组之后得到了结果EMPNO NMS SUM(VAL)
1 a 15
1 b 24
2 a 50
你有SUM(SUM(VAL)) OVER(PARTITION BY NMS)
EMPNO NMS SUM(VAL) SUM(SUM(VAL)) OVER(PARTITION BY NMS)
1 a 15 65 (15+50 for NMS = a)
1 b 24 24 (24 for NMS = b)
2 a 50 65 (15+50 for NMS = a)
你有SUM(SUM(VAL)) OVER(PARTITION BY EMPNO)
EMPNO NMS SUM(VAL) SUM(SUM(VAL)) OVER(PARTITION BY EMPNO)
1 a 15 39 (15+24 for EMPNO = 1)
1 b 24 39 (15+24 for EMPNO = 1)
2 a 50 50 (50 for EMPNO = 2)