0

I am trying to implement OLAP queries in MySql.

Here is a relation that I am trying to implement queries on

Cart(product_name,shipper_name,quantity).

I tried running the following query:

select product_name,shipper_name, sum(quantity) from Cart group by CUBE(product_name,shipper_name);

The above query results in the following error when executed:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CUBE(product_name,shipper_name)' at line 1

I am using MySql community version 8.0.

I was expecting a relation in output that performs the group by operation according to the cube operation that we have in SQL.

3
  • Is there a way to implement it by using a combination of operations such as group by union etc.? or can we simply not do it in MySql? Commented Mar 20, 2023 at 12:58
  • You need to provide sample data and expected output based on the sample data and we may be able to suggest a solution. Without this, it is anyone's guess what output you are looking for. It may be as simple as using the rollup modifier to rewrite your query. Commented Mar 20, 2023 at 14:05
  • Thank You. I was able to implement using roll-up and other operation. Commented Mar 20, 2023 at 18:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.