oracle分组求和并求百分比

2020-06-15 教育 87阅读
WITH t1 AS(
SELECT 'a' c1, 2 c2 FROM dual
UNION ALL SELECT 'a' c1, 4 c2 FROM dual
UNION ALL SELECT 'b' c1, 1 c2 FROM dual
UNION ALL SELECT 'b' c1, 8 c2 FROM dual
)
SELECT c1, SUM(c2), SUM(c2)/(SELECT SUM(c2) FROM t1) FROM t1 GROUP BY c1
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com