- 浏览: 1132427 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
ORA-00979: not a GROUP BY expression
当用到组函数时,出现在select列表中的字段,如果没有在组函数中,那么必须出现在group by子句中!
Cause:The GROUP BY clause does not contain all the expressions in the SELECT clause. SELECT expressions that are not included in a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, must be listed in the GROUP BY clause.
Action:Include in the GROUP BY clause all SELECT expressions that are not group function arguments.
ORA-00937: not a single-group group function
如果在select列表项中除了包含聚合函数外,还包含了表的某些列,那么你将必须使用group by语句。
Cause:A SELECT list cannot include both a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, and an individual column expression, unless the individual column expression is included in a GROUP BY clause.
Action:Drop either the group function or the individual column expression from the SELECT list or add a GROUP BY clause that includes all individual column expressions listed.
在where子句和group by子句中不允许使用聚合函数,否则会报:
ORA-00934: group function is not allowed here
Cause:One of the group functions, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, was used in a WHERE or GROUP BY clause.
Action:Remove the group function from the WHERE or GROUP BY clause. The desired result may be achieved by including the function in a subquery or HAVING clause.
http://techonthenet.com/oracle/errors/ora00934.php
引用
Cause:You tried to execute an SQL statement that included one of the group functions (ie: MIN, MAX, SUM, COUNT) in either the WHERE clause or the GROUP BY clause.
Action:The options to resolve this Oracle error are:
1 Try removing the group function from the WHERE clause or GROUP BY clause. If required, you can move the group function to the HAVING clause.
For example, if you tried to execute the following SQL statement:
You could correct this statement by using the HAVING clause as follows:
2 You could also try moving the group by function to a subquery.
For example, if you tried to execute the following SQL statement:
You could correct this statement by using a subquery as follows:
Action:The options to resolve this Oracle error are:
1 Try removing the group function from the WHERE clause or GROUP BY clause. If required, you can move the group function to the HAVING clause.
For example, if you tried to execute the following SQL statement:
SELECT department, SUM(sales) as "Total sales" FROM order_details WHERE SUM(sales) > 1000 GROUP BY department;You will receive the error "ORA-00934: group function is not allowed here"
You could correct this statement by using the HAVING clause as follows:
SELECT department, SUM(sales) as "Total sales" FROM order_details GROUP BY department HAVING SUM(sales) > 1000;
2 You could also try moving the group by function to a subquery.
For example, if you tried to execute the following SQL statement:
SELECT department, SUM(sales) as "Total sales" FROM order_details WHERE SUM(sales) > 1000 GROUP BY department;You will receive the error "ORA-00934: group function is not allowed here"
You could correct this statement by using a subquery as follows:
SELECT order_details.department, SUM(order_details.sales) as "Total sales" FROM order_details, (select department, SUM(sales) as Sales_compare FROM order_details GROUP BY department) subquery1 WHERE order_details.department = subquery1.department AND subquery1.Sales_compare > 1000 GROUP BY order_details.department;
本博客相关解释:http://wuaner.iteye.com/blog/513099
引用
Illegal Queries Using Group Functions:
- You cannot use the WHERE clause to restrict groups. (即where子句中不允许使用聚合函数)
- You use the HAVING clause to restrict groups.(可以使用having子句为聚合函数加限定条件)
- You cannot use group functions in the WHERE clause.(即where子句中不允许使用聚合函数)
- You cannot use the WHERE clause to restrict groups. (即where子句中不允许使用聚合函数)
- You use the HAVING clause to restrict groups.(可以使用having子句为聚合函数加限定条件)
- You cannot use group functions in the WHERE clause.(即where子句中不允许使用聚合函数)
group by和order by的列可以不在select中;
用到了聚合函数并同时使用group by和order by时,select和order by中不在聚合函数里的columns必须都出现在group by中!
如,下面的写法会报“not a GROUP BY expression”:
select deptno, sum(sal) from emp group by deptno order by deptno,job
正确的写法是:
select deptno, sum(sal) from emp group by deptno,job order by deptno,job
发表评论
-
Oracle: minus | in | exists
2012-09-05 13:49 1405解释及例子: MINUS Query: http://www. ... -
一个奇怪的Oracle sql问题
2011-01-13 16:13 1315select A.M,B.N from Table1 A ... -
Oracle Analytic Functions:RANK, DENSE_RANK, FIRST and LAST;PARTITION BY
2010-12-13 17:02 1282Oracle/PLSQL: Rank Function: ht ... -
Oracle Analytic Functions:RANK, DENSE_RANK, FIRST and LAST
2010-12-13 17:02 1226Oracle/PLSQL: Rank Function: ht ... -
Oracle:Collections Records Type %TYPE %ROWTYPE
2010-11-09 22:27 1236PL/SQL Collections and Records: ... -
Oracle Cursor 游标
2010-11-09 20:44 3006Oracle中Cursor介绍: http://www.ite ... -
Oracle 锁机制
2010-09-19 20:12 3687Oracle多粒度封锁机制研究: http://www.itp ... -
Oracle Data Dictionary 数据字典
2010-09-19 16:44 1492Oracle数据字典查阅: http://download.o ... -
Oracle Sign Function
2010-09-17 14:52 1443Oracle/PLSQL: Sign Function: ht ... -
Oracle Built-In Functions: Next_Day and Last_Day
2010-09-16 17:09 1491next_day(date,char): 它用来返回从第一个 ... -
Oracle Procedure 存储过程
2010-09-16 08:36 1324Oracle/PLSQL: Creating Procedur ... -
Oracle Exception Handle 异常处理
2010-09-15 13:00 2045Handling PL/SQL Errors: http:// ... -
Oracle 性能工具 : Explain plan、Autotrace、Tkprof
2010-09-14 18:07 2197Oracle: 三个内置的性能工具包 Explain plan ... -
关于Oracle数据和对象的导入导出 [转]
2010-09-14 10:25 1232关于Oracle数据和对象的导入导出 [转]: http:// ... -
Oracle jobs(DBMS_JOB and DBMS_SCHEDULER)
2010-07-21 14:14 7684写PL/SQL procedure的时候,一定要写的够健壮、够 ... -
Oracle 各种注释
2010-07-20 14:19 3581为SQL语句添加注释: http://do ... -
Oracle 监听 本地Net服务名 配置
2010-07-20 10:32 1293Oracle数据库配置: http://shupili1410 ... -
[Oracle]Difference between a database and an instance(数据库 实例 区别)
2010-07-20 09:31 1462Difference between a database a ... -
Oracle Bulk Collect
2010-07-16 10:03 1348On BULK COLLECT: http://www.ora ... -
Oracle/PLSQL: FOR Loop 循环语句
2010-07-15 16:43 9283Oracle/PLSQL: FOR Loop: http:// ...
相关推荐
Oracle常见错误代码 Oracle常见错误代码 以下表格中收集了Oracle中常见错误代码。
ORACLE常见错误代码的分析与解决ORACLE常见错误代码的分析与解决ORACLE常见错误代码的分析与解决ORACLE常见错误代码的分析与解决
Oracle常见错误总结
Oracle常见错误代码的分析与解决Oracle常见错误代码的分析与解决Oracle常见错误代码的分析与解决Oracle常见错误代码的分析与解决
浅谈Oracle常见错误处理,Oracle公司工程师列举的常见错误及处理方法。
oracle常见错误分析一览表,共收录19737个常见的oracle错误分析,和大家分享!
oracle常见错误代码,如ORA-XXXX类型的错误及其解决方法
oracle常见错误精集 大多数的oracle基础问题都可以找到答案
oracle常见错误代码的分析与解决,oracle常见错误代码的分析与解决
Oracle常见错误处理 by lunar大神
oracle数据库常见错误码的原因和解决的办法
Oracle常见错误代码的分析与解决,从这里可以看到那些常见的错误并有解决方案
oracle常见错误代码的分析与解决说明文档
Oracle 常见错误 ORA-04031(PDF) 如何解决ORA-04031 错误 文章内容 1.和共享池(shared pool)相关的实例参数 2.诊断ORA-04031 错误 3.解决ORA-04031 错误 • 已知的Oracle BUG • 共享池碎片 o V$SQLAREA 视图 o X$...