How to partial column using GROUP BY CUBE in sql (Error in SQL statement: UnsupportedOperationException:)

Viewed 43

I would like to use GROUP BY CUBE with some columns. I have tried this way (which I found from many website) but I get the error

Error in SQL statement: UnsupportedOperationException:

Here is the query:

SELECT a, b, c, SUM(d) AS d
FROM table
GROUP BY a, CUBE(b, c)

I'm not sure if I did something wrong or you can suggest other way.

Thanks in advance.

I separate 'a' outside cube because I don't want to have null (total) in 'a' column as I think it will help to reduce the time as well.

1 Answers

The general syntax of CUBE extension is as

SELECT 
    col1, col2, aggregate_function(col3)
FROM
    table_name
GROUP BY CUBE(col1, col2)

So change your query as

SELECT
    a, b, c, sum(d) as d
FROM
    table
GROUP BY CUBE(a, b, c)
Related