我正在使用以下查询从视图中选择数据
SELECT * FROM "SCH"."MyView"
如果我添加ORDER BY
SELECT * FROM "SCH"."MyView"
ORDER BY Name
我收到以下错误
[Err] ORA-00979: not a GROUP BY expression
Oracle查询引擎是否将此转换为无效查询?如何开始对此类问题进行故障排除?
这是“SCH”的简化。“MyView”
SELECT
Name,
(subquery) AS Foo,
(subquery) AS Bar
FROM
"SCH"."AnotherView"
GROUP BY
Name
如果删除子查询,我可以使用ORDER BY而不会出现错误消息。子查询如下:
( SELECT f.UnitPrice FROM "SCH"."AnotherView" f WHERE f.Name = main.Name AND f.Category = 'x' AND rownum < 2 ) AS priceX
( SELECT b.UnitPrice FROM "SCH"."AnotherView" b WHERE b.Name = main.Name AND b.Category = 'y' AND rownum < 2 ) AS priceY
编辑:如果我添加“WHERE rownum&lt; 9999999”,我就摆脱了错误。我们正在运行版本10.2.0.4.0 64位。
答案 0 :(得分:0)
也许您尝试执行包含SELECT
函数的GROUP BY
语句(即:MIN
,MAX
,SUM
,COUNT
)和SELECT
列表中不在GROUP BY
子句中的表达式。