ORACLE-BASE - ROLLUP, CUBE, GROUPING Functions and GROUPING SETS
看不懂的可以来问
-------------------------------------------------------------------------------------------------------------------------------
完了,我也看不懂了
思考一下几个SQL 的result sets:
SELECT fact_1_id,
fact_2_id,
fact_3_id,
SUM(sales_value) AS sales_value,
GROUPING_ID(fact_1_id, fact_2_id, fact_3_id) AS grouping_id
FROM dimension_tab
GROUP BY GROUPING SETS((fact_1_id, fact_2_id), (fact_1_id, fact_3_id),())
ORDER BY fact_1_id, fact_2_id, fact_3_id;
SELECT fact_1_id,
fact_2_id,
SUM(sales_value) AS sales_value,
GROUPING_ID(fact_1_id, fact_2_id) AS grouping_id
FROM dimension_tab
GROUP BY rollup((fact_1_id,fact_2_id),fact_1_id)
ORDER BY fact_1_id, fact_2_id;
SELECT fact_1_id,
fact_2_id,
SUM(sales_value) AS sales_value,
GROUPING_ID(fact_1_id, fact_2_id) AS grouping_id
FROM dimension_tab
GROUP BY GROUPING SETS((fact_1_id, fact_2_id)),rollup(fact_1_id)
ORDER BY fact_1_id, fact_2_id;
标签:Functions,sales,value,SETS,id,fact,GROUPING
From: https://blog.csdn.net/weixin_44875522/article/details/145265905