Presto如何grouping set?

Presto中存在一种grouping操作。

grouping operation返回一个转换为十进制的位,指示分组中存在哪些列。

它必须与GROUPING SETSROLLUPCUBEGROUP BY结合使用,并且其参数必须与相应的GROUPING SETS,ROLLUP,CUBE或GROUP BY子句中引用的列完全匹配

SELECT origin_state, origin_zip, destination_state, sum(package_weight),
       grouping(origin_state, origin_zip, destination_state)
FROM shipping
GROUP BY GROUPING SETS (
        (origin_state),
        (origin_state, origin_zip),
        (destination_state));
作者:Qingyun
                
comments powered by Disqus