我想执行以下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;
当我执行它时抛出异常
命令行错误:3列:7
错误报告 - SQL错误:
ORA-00934:Groepsfunctie是一个非常小的东西 00934. 00000 - “此处不允许使用群组功能”
我做错了什么?
答案 0 :(得分:1)
您无法在aggregate
中使用group by
功能。从count
中删除聚合函数group by
。
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;