抛出Oracle sql,ora:此处不允许使用组函数

时间:2015-03-12 14:55:00

标签: sql oracle exception-handling

我想执行以下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 - “此处不允许使用群组功能”

我做错了什么?

1 个答案:

答案 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;