不是 Group By 表达式:不清楚如何解决该问题
Not a Group By expression : Unclear on how to fix the issue
我不确定这里的主要问题,我相信我的代码是正确的,但我不知道如何解决“ORA-00979:不是 GROUP BY 表达式”的问题。
SELECT distinct customer_city, customer_state, COUNT(*)
FROM customers
WHERE customer_state not in ('TX', 'OR')
GROUP BY ROLLUP(customer_state);
"distinct" 不适用于组表达式;您的“分组依据”子句需要包含所有 non-grouped 列。试试这个:
SELECT customer_city, customer_state, COUNT(*)
FROM customers
WHERE customer_state not in ('TX', 'OR')
GROUP BY ROLLUP (customer_city, customer_state);
所选列必须是 ROLL UP 中分组依据的一部分,如下所示。
SELECT customer_city, customer_state, COUNT(*)
FROM customers
WHERE customer_state not in ('TX', 'OR')
GROUP BY ROLLUP(customer_city, customer_state);
我不确定这里的主要问题,我相信我的代码是正确的,但我不知道如何解决“ORA-00979:不是 GROUP BY 表达式”的问题。
SELECT distinct customer_city, customer_state, COUNT(*)
FROM customers
WHERE customer_state not in ('TX', 'OR')
GROUP BY ROLLUP(customer_state);
"distinct" 不适用于组表达式;您的“分组依据”子句需要包含所有 non-grouped 列。试试这个:
SELECT customer_city, customer_state, COUNT(*)
FROM customers
WHERE customer_state not in ('TX', 'OR')
GROUP BY ROLLUP (customer_city, customer_state);
所选列必须是 ROLL UP 中分组依据的一部分,如下所示。
SELECT customer_city, customer_state, COUNT(*)
FROM customers
WHERE customer_state not in ('TX', 'OR')
GROUP BY ROLLUP(customer_city, customer_state);