Oracle sql, ora 被抛出: group function is not allowed here
Oracle sql, ora is thrown: group function is not allowed here
我想执行以下 SQL 脚本
SELECT
t1.Technology,
count(t1.trax_id) as "Current number of items",
TO_CHAR(MAX(TO_DATE('20000101','yyyymmdd') +
(SYSDATE - t1.time_event)),'hh24:mi:ss') as "max_ages"
FROM
dm_procmon t1
GROUP BY
t1.Technology, count(t1.trax_id),
TO_CHAR(MAX(TO_DATE('20000101','yyyymmdd') +
(SYSDATE - t1.time_event)), 'hh24:mi:ss')
HAVING
COUNT(t1.trax_id) = 1;
当我执行它时抛出异常
Error at Command Line : 3 Column : 7
Error report - SQL Error:
ORA-00934: Groepsfunctie is hier niet toegestaan.
00934. 00000 - "group function is not allowed here"
我做错了什么?
您不能在 group by
中使用 aggregate
函数。从 group by
中删除聚合函数 count
。
SELECT t1.Technology,
Count(t1.trax_id) AS "Current number of items",
To_char(Max(To_date('20000101', 'yyyymmdd') + ( SYSDATE - t1.time_event )), 'hh24:mi:ss') AS "max_ages"
FROM dm_procmon t1
GROUP BY t1.Technology
HAVING Count(t1.trax_id) = 1;
我想执行以下 SQL 脚本
SELECT
t1.Technology,
count(t1.trax_id) as "Current number of items",
TO_CHAR(MAX(TO_DATE('20000101','yyyymmdd') +
(SYSDATE - t1.time_event)),'hh24:mi:ss') as "max_ages"
FROM
dm_procmon t1
GROUP BY
t1.Technology, count(t1.trax_id),
TO_CHAR(MAX(TO_DATE('20000101','yyyymmdd') +
(SYSDATE - t1.time_event)), 'hh24:mi:ss')
HAVING
COUNT(t1.trax_id) = 1;
当我执行它时抛出异常
Error at Command Line : 3 Column : 7
Error report - SQL Error:
ORA-00934: Groepsfunctie is hier niet toegestaan.
00934. 00000 - "group function is not allowed here"
我做错了什么?
您不能在 group by
中使用 aggregate
函数。从 group by
中删除聚合函数 count
。
SELECT t1.Technology,
Count(t1.trax_id) AS "Current number of items",
To_char(Max(To_date('20000101', 'yyyymmdd') + ( SYSDATE - t1.time_event )), 'hh24:mi:ss') AS "max_ages"
FROM dm_procmon t1
GROUP BY t1.Technology
HAVING Count(t1.trax_id) = 1;