【问题标题】:Oracle sql, ora is thrown: group function is not allowed hereoracle sql, ora 抛出:这里不允许组函数
【发布时间】:2015-03-12 14:54:59
【问题描述】:

我想执行下面的 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 是 hier niet toegestaan​​。
00934. 00000 - “此处不允许使用群组功能”

我做错了什么?

【问题讨论】:

    标签: sql oracle exception-handling


    【解决方案1】:

    您不能在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; 
    

    【讨论】:

    • @user4663023 - 错过检查更新的最大功能立即尝试
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    相关资源
    最近更新 更多