Is there a way to simulate GROUP BY WITH CUBE in MySql?

本小妞迷上赌 提交于 2019-12-10 04:28:33

问题


MySql supports GROUP BY WITH ROLLUP which will return aggregates for the last x of the n columns in the group by but does not support GROUP BY WITH CUBE to take all combinations of the n columns and take aggregates.

I can simulate this by doing unions of GROUP BY WITH ROLLUP queries, but MySql is materializing my subquery multiple times. I am using a group by on a large subquery, so this is suboptimal. Is there a way to solve this without temporary tables?


回答1:


Short answer: No.

Long answer: You may install an open source data warehouse with GROUP BY WITH CUBE support which is using Mysql as a storage engine, such as Pentaho.



来源:https://stackoverflow.com/questions/7085236/is-there-a-way-to-simulate-group-by-with-cube-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!