I have query in my structure trying run in PHPMYADMIN. I am trying to run CUBE query for OLAP operation, this is my query :
SELECT QUARTER, REGION, SUM(SALES) FROM salestable GROUP BY CUBE (QUARTER, REGION)
I have also tried this query :
SELECT salestable.QUARTER, salestable.REGION, SUM(salestable.SALES) FROM salestable GROUP BY CUBE (salestable.QUARTER, salestable.REGION)
but it showing this error :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(QUARTER, REGION) LIMIT 0, 25' at line 3
I tried to open the page to check syntax but it shows page not found.
Advertisement
Answer
I don’t think MySQL supports CUBE
as a GROUP BY
modifier, but you can use WITH ROLLUP
:
SELECT st.QUARTER, st.REGION, SUM(st.SALES) FROM salestable st GROUP BY st.QUARTER, st.REGION WITH ROLLUP;