Grouping_ID oracle 函数语法错误
Grouping_ID syntax error in oracle with functions
谁能指出以下语法中的错误。
这工作正常。
SELECT col1,col2,grouping_id(col1)col3,substr(col2,1,5)col4
FROM tab1
GROUP BY col1, col2,col3,col4
HAVING GROUPING_ID(col1)<=5 order by 1,2,3,4;
这不是:
SELECT col1,col2,grouping_id(col1)col3,substr(col2,1,5)col4
FROM tab1
GROUP BY col1, col2,col3,col4
HAVING GROUPING_ID(col1,substr(col2,1,2))<=5 order by 1,2,3,4;
如何在oracle中使用grouping_id中的函数?
错误msg:ORA-00979: 不是 GROUP BY 表达式
substr(col2,1,2)
不是按表达式分组,但 substr(col2,1,5)
是。
您应该添加到 SELECT
投影 substr(col2,1,2)
或将 substr(col2,1,2)
替换为 substr(col2,1,5)
in GROUP BY
谁能指出以下语法中的错误。
这工作正常。
SELECT col1,col2,grouping_id(col1)col3,substr(col2,1,5)col4
FROM tab1
GROUP BY col1, col2,col3,col4
HAVING GROUPING_ID(col1)<=5 order by 1,2,3,4;
这不是:
SELECT col1,col2,grouping_id(col1)col3,substr(col2,1,5)col4
FROM tab1
GROUP BY col1, col2,col3,col4
HAVING GROUPING_ID(col1,substr(col2,1,2))<=5 order by 1,2,3,4;
如何在oracle中使用grouping_id中的函数?
错误msg:ORA-00979: 不是 GROUP BY 表达式
substr(col2,1,2)
不是按表达式分组,但 substr(col2,1,5)
是。
您应该添加到 SELECT
投影 substr(col2,1,2)
或将 substr(col2,1,2)
替换为 substr(col2,1,5)
in GROUP BY