title: Is there a way to simulate GROUP BY WITH CUBE in MySql?
body: <p>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.</p>
  
  <p>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?</p>