ORA-00979: not a GROUP BY expression报错处理

php中文网
发布: 2016-06-07 17:32:07
原创
4083人浏览过

环境:Oracle Database 11gR2(11.2.0.2) on Linux 故障现象: 执行Group By语句报错ORA-00979。具体的SQL如下:SQLgt; select

环境:oracle database 11gr2(11.2.0.2) on linux
故障现象: 执行group by语句报错ora-00979。
具体的sql如下:
sql> select  a.d1,a.exit_type,round(a.cnt1/b.cnt2*100,2) from
  2  (select substr(login_date,1,8) d1,exit_type,count(*) cnt1 from xxx_connect_log group by substr(login_date,1,8),exit_type) a,
  3  (select substr(login_date,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(login_date,1,8) ) b
  4  where a.d1=b.d2 order by a.d1,a.exit_type;
(select substr(login_date,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(login_date,1,8) ) b
                                                                  *
error at line 3:
ora-00979: not a group by expression


这条语句在其他大区的DB上执行均OK,在体验服DB上执行报错。从语法上看,确实是完全没问题的。


碰到这种ORA-报错的情况,我们可以通过设置ErrorStack对错误堆栈进行跟踪,将错误的后台信息比较详尽的转储到跟踪文件,,供分析研究。


ErrorStack的四个级别及说明:
0 Error stack only
1 Error stack and function call stack
2 As level 1 plus the process state
3 As level 2 plus the context area


ErrorStack仅在特定的错误出现的时候才被触发。可以在实例或者会话级别进行设置。


下面我们进行979的ErrorStack跟踪:
SQL> alter system set events='979 trace name errorstack forever,level 3';

System altered.

SQL> select  a.d1,a.EXIT_type,round(a.cnt1/b.cnt2*100,2) from
  2  (select substr(LOGIN_DATE,1,8) d1,EXIT_type,count(*) cnt1 from xxx_connect_log group by substr(LOGIN_DATE,1,8),EXIT_type) a,
  3  (select substr(LOGIN_DATE,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(LOGIN_DATE,1,8) ) b
  4  where A.d1=B.d2 order by a.d1,a.EXIT_type;
(select substr(LOGIN_DATE,1,8) d2 ,count(*) cnt2 from xxx_connect_log group by substr(LOGIN_DATE,1,8) ) b
                                                                  *
ERROR at line 3:
ORA-00979: not a GROUP BY expression


SQL> alter system set events='979 trace name errorstack off';

System altered.

相关阅读:

SPFILE 错误导致数据库无法启动(ORA-01565)

ORA-01172、ORA-01151错误处理

ORA-00600 [2662]错误解决

ORA-01078 和 LRM-00109 报错解决方法

ORA-00471 处理方法笔记

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号