Cube Operators on Impala
We can use impala windo functions but instead of single column output, you will get 3 columns.
SELECT origin_state, destination_state, SUM(package_weight) OVER (PARTITION BY origin_state, destination_state) AS pkgwgrbyorganddest, SUM(package_weight) OVER (PARTITION BY origin_state) AS pkgwgrbyorg, SUM(package_weight) OVER (PARTITION BY destination_state) AS pkgwgrbydest FROM shipping;