"not a GROUP BY expression" error when using EclipseLink
I'm using EcliseLink 2.3.0
The follow SQL can be executed successfully.
select to_char(o.taskDate, 'YYYY/MM'), sum(o.plannedHrs) from TaskItem o group by to_char(o.taskDate, 'YYYY/MM');
But the JPQL has an error when it gets excuted.
select FUNC('to_char', o.taskDate, 'YYYY/MM'), sum(o.plannedHrs) from TaskItem o group by FUNC('to_char', o.taskDate, 'YYYY/MM')
ERROR LOG:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00979: not a GROUP BY expression
Error Code: 979
Call: SELECT to_char(TASK_DATE, ?), SUM(PLANNED_HRS) FROM ORA47111.S_PROJ_PLAN_ITEM GROUP BY to_char(TASK_DATE, ?)
bind => [2 parameters bound]
Query: ReportQuery(referenceClass=TaskItemDAO sql="SELECT to_char(TASK_DATE, ?), SUM(PLANNED_HRS) FROM ORA47111.S_PROJ_PLAN_ITEM GROUP BY to_char(TASK_DATE, ?)")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2592)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:2535)
at org.eclipse.persistence.queries.ReportQuery.executeDatabaseQuery(ReportQuery.java:846)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
at projapis.projrollup.beans.ManagedTaskItemDAOBean.calcResourcePlannedHrsInMonth(ManagedTaskItemDAOBean.java:329)
at projapis.projrollup.beans.ManagedTaskItemDAOBean.main(ManagedTaskItemDAOBean.java:522)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00979: not a GROUP BY expression
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:931)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:607)
... 22 more
Any suggestion?
Thanks a lot.
Edited by: sgao on Jul 19, 2011 11:13 PM
Hello,
Unfortunately it is the driver complaining about the SQL that is generated, but I see no major difference from the SQL in the exception:
SELECT to_char(TASK_DATE, ?), SUM(PLANNED_HRS) FROM ORA47111.S_PROJ_PLAN_ITEM GROUP BY to_char(TASK_DATE, ?)
and the SQL you state works other than it looks like JPQL not SQL: select to_char(o.taskDate, 'YYYY/MM'), sum(o.plannedHrs) from TaskItem o group by to_char(o.taskDate, 'YYYY/MM');
Does it work if the SQL in the exception is executed as a native query? Since this the driver complaining about what looks correct, I would look at the driver/database versions to see if there is a later version that might have a bug that has been fixed.
Best Regards,
Chris
Similar Messages
-
Getting "ORA-00979: not a GROUP BY expression" error in Inline query
Hello all,
The following query when run in SCOTT user gives "ORA-00979: not a GROUP BY expression" error.
If I remove the TRUNC function from the outer query's group by clause, then it fetches
(My actual query is something similar to the following query. I have given emp, dept tables for convenience's sake)
select e.empno,e.ename, AVG(e.SAL), trunc(e.hiredate),
(select sum(sal) from emp
where hiredate = e.hiredate) salary
from emp e
group by e.DEPTNO,e.EMPNO,e.ENAME, trunc(e.hiredate)
Pls suggest how this error can be avoided.
Regards,
SamWhy not this?
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.02
satyaki>
satyaki>
satyaki>select e.empno,
2 e.ename,
3 AVG(e.SAL),
4 trunc(e.hiredate),
5 (
6 select sum(sal)
7 from emp
8 where hiredate = e.hiredate
9 ) salary
10 from emp e
11 group by e.DEPTNO,
12 e.EMPNO,
13 e.ENAME,
14 e.hiredate;
EMPNO ENAME AVG(E.SAL) TRUNC(E.H SALARY
7934 MILLER 1887.6 23-JAN-82 5583.6
7698 Glen 1848 23-JAN-82 5583.6
7788 SCOTT 598.95 19-APR-87 598.95
7900 JAMES 1379.4 03-DEC-81 6650.16
7521 WARD 226.88 22-FEB-81 226.88
7599 BILLY 4500 10-JUN-09 4500
2222 sp 1200 14-SEP-09 1200
7902 FORD 5270.76 03-DEC-81 6650.16
7566 Smith 1848 23-JAN-82 5583.6
7654 MARTIN 1815 28-SEP-81 1815
7839 KING 7260 17-NOV-81 7260
EMPNO ENAME AVG(E.SAL) TRUNC(E.H SALARY
7844 TURNER 2178 08-SEP-81 2178
7876 ADAMS 159.72 23-MAY-87 159.72
13 rows selected.
Elapsed: 00:00:00.03
satyaki>Regards.
Satyaki De. -
GROUP BY and ..not a group by expression ERROR
Hi, I have the following table
===========
STUDENTS
===========
ID NAME TESTDATE MARKS
=== ====== ========= ======
1 JOHN 2007-10-01 10
1 JOHN 2007-10-02 11
1 JOHN 2007-10-02 8
2 MARY 2007-10-01 10
2 MARY 2007-10-02 7
I want to list student with maximum mark he/scored immaterial of the test - date
The following query does it:
SELECT ID, MAX(MARKS)
FROM STUDENTS
GROUP BY ID
RESULT -
ID MAX(MARKS)
=== ===========
1 11
2 10
Now, I want to show the NAME and TESTDATE in the result (remember, only for the max marks)
So I write:
SELECT ID, NAME, TESTDATE, MAX(MARKS)
FROM STUDENTS
GROUP BY ID
XXXXXXX ERROR - not a group by expression - Agreed that TESTDATE & NAME are not in group by expression. I don't want to group by TESTDATE/NAME as it won't yeild the result I am looking for.
What I am looking for is the same result from above with additional fields.
How to get around this problem? any help is highly appreciated.
THANKS IN ADVANCE.Try this (Not tested)
SELECT ID, max(NAME) keep(dense_rank last order by marks) name,
max(testdate) keep(dense_rank last order by marks) testdate,
MAX(MARKS) max_mark
FROM STUDENTS
GROUP BY ID;Or using a subquery...
select id,name,testdate,marks
from
(select id,name,testdate,marks,
row_number() over(partition by id order by marks desc) rn
from students)
where rn = 1; -
Not a group by expression error
1st column is status codes :StatusCode
2nd column is thier defnition :Definition
3rd column is no of times each code occured in those records :Notimes
Example: 302 , moved data, 1260
And now i want to know the % of each code occurence.
select status_code,((notimes* 100)/sum(TOTAL_COUNT)) AS percent from Report_status,(SELECT COUNT(*) AS TOTAL_COUNT FROM Report_status)
group by status_code.
Could anyone help me with this query
Getting not agroup by expression.SQL> create table mytable
2 as
3 select l id
4 , case when l < 1261 then 302 else 303 end statuscode
5 , case when l < 1261 then 'moved data' else 'new data' end definition
6 from (select level l from dual connect by level <= 1500)
7 /
Tabel is aangemaakt.
SQL> select statuscode
2 , definition
3 , count(*) notimes
4 , 100 * ratio_to_report(count(*)) over () percentage
5 from mytable
6 group by statuscode
7 , definition
8 /
STATUSCODE DEFINITION NOTIMES PERCENTAGE
302 moved data 1260 84
303 new data 240 16
2 rijen zijn geselecteerd.Regards,
Rob. -
GROUP BY with parameter - cause error -ORA-00979: not a GROUP BY expression
I generate a query via PreparedStatement. For example:
SELECT when, value FROM test GROUP BY ?;
PrepState.toString(1, "when");
That causing error: ORA-00979: not a GROUP BY expression
My application using query like:
SELECT to_char(data,1), SUM(vlue) as sum FROM test GROUP BY to_char(data, 2);
PrepState.toString(1, "YYYY-MM");
PrepState.toString(2, "YYYY-MM");Ah. Reproduced in the first chunk of PL/SQL below.
The second chunk is a workaround.
Basically, SQL is parsed by the syntax engine and optimizer to get an execution plan. Then you can have a sequence of "bind, execute, fetch, fetch, fetch..., bind, execute..."
Since you can have multiple binds for a single SQL parse, then the fact that the first set of binds all happen to have the same value doesn't mean the next set will.
The optimizer needs to be 100% sure that the value in the select must always be the same as the value in the group by, so you can't have two separate (and therefore potentially different) bind variable mappings. [Given the right circumstances, the optimizer might do all sorts of tricks, such as using materialized views and function-based indexes.]
Misleadingly, it actually fails on the 'EXECUTE' step of DBMS_SQL rather than the PARSE.
declare
v_sql varchar2(1000) :=
'select to_char(created,:b1), count(*) '||
' from user_objects u '||
' group by to_char(created,:b2) '||
' order by to_char(created,:b3)';
v_fmt varchar2(10) := 'YYYY';
v_cur number;
v_ret_str varchar2(10);
v_ret_num number;
v_ret number;
begin
v_cur := dbms_sql.open_cursor;
dbms_sql.parse(v_cur, v_sql, dbms_sql.native );
dbms_sql.define_column_char (v_cur, 1, v_ret_str, 10);
dbms_sql.define_column (v_cur, 2, v_ret_num);
dbms_sql.bind_variable( v_cur, ':b1', v_fmt );
dbms_sql.bind_variable( v_cur, ':b2', v_fmt );
dbms_sql.bind_variable( v_cur, ':b3', v_fmt );
v_ret := dbms_sql.execute( v_cur );
WHILE ( dbms_sql.fetch_rows(v_cur) > 0 ) LOOP
dbms_sql.column_value_char (v_cur, 1, v_ret_str );
dbms_sql.column_value (v_cur, 2, v_ret_num );
dbms_output.put_line('>'||v_ret_str||':'||v_ret_num);
END LOOP;
end;
declare
v_sql varchar2(1000) :=
'select to_char(created,f.fmt), count(*) '||
' from user_objects u, (select :b1 fmt from dual) f '||
' group by to_char(created,f.fmt) '||
' order by to_char(created,f.fmt)';
v_fmt varchar2(10) := 'YYYY';
v_cur number;
v_ret_str varchar2(10);
v_ret_num number;
v_ret number;
begin
v_cur := dbms_sql.open_cursor;
dbms_sql.parse(v_cur, v_sql, dbms_sql.native );
dbms_sql.define_column_char (v_cur, 1, v_ret_str, 10);
dbms_sql.define_column (v_cur, 2, v_ret_num);
dbms_sql.bind_variable( v_cur, ':b1', v_fmt );
v_ret := dbms_sql.execute( v_cur );
WHILE ( dbms_sql.fetch_rows(v_cur) > 0 ) LOOP
dbms_sql.column_value_char (v_cur, 1, v_ret_str );
dbms_sql.column_value (v_cur, 2, v_ret_num );
dbms_output.put_line('>'||v_ret_str||':'||v_ret_num);
END LOOP;
end;
/ -
Not a GROUP BY expression - Oracle 10g bug?
Hi,
I am geting 00979. 00000 - "not a GROUP BY expression" error on Oracle 10g 10.2.0.4.0 - 64bit Production.
To illustrate my problem I created following example.
Let think I have some shop with clothes. Everytime I sell something, I store this information in the database - storing actual time, clothes type (trousers, socks, ...) and the size of the piece (M, L, XL, ...).
Now, system counts statistics every hour. So it goes thrue the table with sold pieces and counts the number of pieces per clothes type and per size from the beginning of the day. It is important to realize that it is from the beginning of the day. Because of that, the number of sold pieces in the statistical table grows every hour (or is at least on the same value as in previous hour).
Now, from this statistical table I need to make new statistic. I want a statistic how many pieces per size I sold every hour.
I created this query for that:
SELECT TIME, xSIZE, (SOLD - NVL((SELECT SUM(S1.SOLD)
FROM STATISTICS S1
WHERE S1.xSIZE = S.xSIZE
AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
AND TO_CHAR(S1.TIME, 'HH24') != '23'
AND S1.xSIZE IS NOT NULL
GROUP BY TRUNC(S1.TIME, 'HH24'), S1.xSIZE),0)) SOLD
FROM(
SELECT TRUNC(S.TIME, 'HH24') TIME, S.xSIZE, SUM(S.SOLD) SOLD
FROM STATISTICS S
WHERE S.xSIZE IS NOT NULL
GROUP BY TRUNC(S.TIME, 'HH24'), S.xSIZE
--ORDER BY 1 DESC
) S
ORDER BY TIME DESC, xSIZE ASCFirst I select number of sold pieces per hour per size. To get number of sold pieces for particular hour, I need to substract from this value number of sold pieces from previous hour. I decided to do this with parameter query...
Running the query like this I get "not a GROUP BY expression" error. However if I uncomment the "ORDER BY 1 DESC" statement, the query works. I am pretty sure it has to do something with this line:
AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
If you modify this query like this:
SELECT TIME, xSIZE, (SOLD - NVL((SELECT SUM(S1.SOLD)
FROM STATISTICS S1
WHERE S1.xSIZE = S.xSIZE
--AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
AND TO_CHAR(S1.TIME, 'HH24') != '23'
AND S1.xSIZE IS NOT NULL
GROUP BY S1.xSIZE),0)) SOLD
FROM(
SELECT TRUNC(S.TIME, 'HH24') TIME, S.xSIZE, SUM(S.SOLD) SOLD
FROM STATISTICS S
WHERE S.xSIZE IS NOT NULL
GROUP BY TRUNC(S.TIME, 'HH24'), S.xSIZE
--ORDER BY 1 DESC
) S
ORDER BY TIME DESC, xSIZE ASCRemoved joining the tables on truncated time and grouping by the truncated time -> The query does not fail...
And now the best...if you run the first query on Oracle 11g (Release 11.1.0.6.0 - 64bit Production), it works.
Does anybody know why is the first query not working on 10g? Is there some bug or limitation for this server version?
Please don't say me to rewrite the query in another way, I already did it, so it works on 10g as well. I am just curious why it doesn't work on 10g.
Finally here are some data for testing.
CREATE TABLE STATISTICS(
TIME DATE DEFAULT SYSDATE,
TYPE VARCHAR2(20),
xSIZE VARCHAR2(2),
SOLD NUMBER(5,0) DEFAULT 0
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'T-Shirt', 'M', 10);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'M', 3);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'T-Shirt', 'L', 1);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'L', 50);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Trousers', 'XL', 7);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'XL', 3);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'T-Shirt', 'M', 13);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Socks', 'L', 60);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Trousers', 'XL', 15);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Socks', 'XL', 6);Edited by: user12047225 on 20.9.2011 23:12
Edited by: user12047225 on 20.9.2011 23:45It is a known issue when optimizer decides to expand in-line view. You can add something (besides ORDER BY you already used) to in-line view to prevent optimizer from expanding it. For example:
SQL> SELECT TIME,
2 xSIZE,
3 (SOLD - NVL(
4 (
5 SELECT SUM(S1.SOLD)
6 FROM STATISTICS S1
7 WHERE S1.xSIZE = S.xSIZE
8 AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
9 AND TO_CHAR(S1.TIME, 'HH24') != '23'
10 AND S1.xSIZE IS NOT NULL
11 GROUP BY TRUNC(S1.TIME, 'HH24'),
12 S1.xSIZE
13 ),
14 0
15 )
16 ) SOLD
17 FROM (
18 SELECT TRUNC(S.TIME, 'HH24') TIME,
19 S.xSIZE,
20 SUM(S.SOLD) SOLD
21 FROM STATISTICS S
22 WHERE S.xSIZE IS NOT NULL
23 GROUP BY TRUNC(S.TIME, 'HH24'),
24 S.xSIZE
25 --ORDER BY 1 DESC
26 ) S
27 ORDER BY TIME DESC,
28 xSIZE ASC
29 /
SELECT TRUNC(S.TIME, 'HH24') TIME,
ERROR at line 18:
ORA-00979: not a GROUP BY expression
SQL> SELECT TIME,
2 xSIZE,
3 (SOLD - NVL(
4 (
5 SELECT SUM(S1.SOLD)
6 FROM STATISTICS S1
7 WHERE S1.xSIZE = S.xSIZE
8 AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
9 AND TO_CHAR(S1.TIME, 'HH24') != '23'
10 AND S1.xSIZE IS NOT NULL
11 GROUP BY TRUNC(S1.TIME, 'HH24'),
12 S1.xSIZE
13 ),
14 0
15 )
16 ) SOLD
17 FROM (
18 SELECT TRUNC(S.TIME, 'HH24') TIME,
19 S.xSIZE,
20 SUM(S.SOLD) SOLD,
21 ROW_NUMBER() OVER(ORDER BY SUM(S.SOLD)) RN
22 FROM STATISTICS S
23 WHERE S.xSIZE IS NOT NULL
24 GROUP BY TRUNC(S.TIME, 'HH24'),
25 S.xSIZE
26 --ORDER BY 1 DESC
27 ) S
28 ORDER BY TIME DESC,
29 xSIZE ASC
30 /
TIME XS SOLD
20-SEP-11 L 9
20-SEP-11 M 0
20-SEP-11 XL 11
20-SEP-11 L 51
20-SEP-11 M 13
20-SEP-11 XL 10
6 rows selected.
SQL> Or use subquery factoring (WITH clause) + undocumented hint MATERIALIZE:
SQL> WITH S AS (
2 SELECT /*+ MATERIALIZE */ TRUNC(S.TIME, 'HH24') TIME,
3 S.xSIZE,
4 SUM(S.SOLD) SOLD
5 FROM STATISTICS S
6 WHERE S.xSIZE IS NOT NULL
7 GROUP BY TRUNC(S.TIME, 'HH24'),
8 S.xSIZE
9 --ORDER BY 1 DESC
10 )
11 SELECT TIME,
12 xSIZE,
13 (SOLD - NVL(
14 (
15 SELECT SUM(S1.SOLD)
16 FROM STATISTICS S1
17 WHERE S1.xSIZE = S.xSIZE
18 AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
19 AND TO_CHAR(S1.TIME, 'HH24') != '23'
20 AND S1.xSIZE IS NOT NULL
21 GROUP BY TRUNC(S1.TIME, 'HH24'),
22 S1.xSIZE
23 ),
24 0
25 )
26 ) SOLD
27 FROM S
28 ORDER BY TIME DESC,
29 xSIZE ASC
30 /
TIME XS SOLD
20-SEP-11 L 9
20-SEP-11 M 0
20-SEP-11 XL 11
20-SEP-11 L 51
20-SEP-11 M 13
20-SEP-11 XL 10
6 rows selected.
SQL> SY. -
Upgrade database ORA-00979: not a GROUP BY expression in Oracle11g R2
hi,
I am working in Oracle 10g (10.2.0.4) Environement. I want to update Our production database from Oracle 10g to Oracle11g R2(11.2.0.3).
note: OS CentOS X86-64
We follow the migration through import & Export Commands from Production database to New Database.
One Of user having views, while executing that view in 11g R2 Environment it gives the following error.
ORA-00979: not a GROUP BY expression.
When i run this same Query in Oracle10g Environment is executed Successfully without errors or warnings.Please be aware that CentOS is not a supported distro for Oracle installs.
For your error, pl see
SQL used to work in 10G Throws ORA-00979 Not A Group By Expression after upgrading to 11G [ID 813946.1]
ORA-979 bugs on 11.2.0.1 [ID 1085766.1]
ORA-00979 AFTER UPGRADE TO 11G [ID 814423.1]
HTH
Srini -
ORA-00979: not a GROUP BY expression in Oracle11g R2
hi,
I am working in Oracle 9i Environement. I want to update Our production database from Oracle 9i to Oracle11g R2.
Note :- Oracle 9i & 11g R2 are different systems.
We follow the migration through import & Export Commands from Production database to New Database.
One Of user having views, while executing that view in 11g R2 Environment it gives the following error.
ORA-00979: not a GROUP BY expression.
When i run this same Query in Oracle9i Environment is executed Successfully with out errors or warnings.
This type of problem not occurred in all views.
In Problematic view having Decode function with in that another decode method was used & finally group by clause is used.
Please guide to me if any issues in 11g R2 Environment.
Thanx in advance
Vijay Kumar
Edited by: user1672302 on Apr 4, 2012 5:32 PMPl see these MOS Docs
ORA-00979 AFTER UPGRADE TO 11G [ID 814423.1]
SQL used to work in 10G Throws ORA-00979 Not A Group By Expression after upgrading to 11G [ID 813946.1]
HTH
Srini -
Error : not a GROUP BY expression
Hi everyone,
Looks like i need some help here.. :) dont know what it means but im getting this message
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:
Error at Line: 137 Column: 36
this is the function:
function get_path(materialID in number, materialTypeID in number, inTopFolderID in number default null, inMaterialFolderID in number default null, webMode in number default 1)
return varchar2;
and im using it on my query
,(select material_util.get_path(m.material_id, 8, 1021695, min(mf.IP_MATERIALFOLDERID), 1)
from material m, materialfolder mf
where mf.nfx_link = m.MATERIAL_ID
and m.template_id = t.template_id) as Path
looks like min(mf.IP_MATERIALFOLDERID) is having some issues here.. dont know why..
let me know guys..
thanks..
JA example
with testdata as
select 1 idu, 1 value1, 7 value2, 40 value3 from dual union all
select 2 idu, 2 value1, 8 value2, 45 value3 from dual union all
select 3 idu, 3 value1, 9 value2, 50 value3 from dual union all
select 1 idu, 4 value1, 4 value2, 55 value3 from dual union all
select 2 idu, 5 value1, 5 value2, 60 value3 from dual union all
select 3 idu, 6 value1, 2 value2, 65 value3 from dual
select min(value1), avg(value2), max(value1), sum(value3) from testdata;
MIN(VALUE1) AVG(VALUE2) MAX(VALUE1) SUM(VALUE3)
1 5,83333333333333333333333333333333333333 6 315
Calculate the aggregated functions with all the data of the table.
select idu, min(value1), avg(value2), max(value1), sum(value3) from testdata;
Error SQL: ORA-00937:
00937. 00000 - "not a single-group group function"
Oracle don't know about what values have to calculate the aggrgates functions because there are not aggregated values in the select.
select idu, min(value1), avg(value2), max(value1), sum(value3) from data group by idu;
IDU MIN(VALUE1) AVG(VALUE2) MAX(VALUE1) SUM(VALUE3)
1 1 5,5 4 95
2 2 6,5 5 105
3 3 5,5 6 115
Calculate the aggregated functions in order at idu value. -
Error ORA-00979: not a GROUP BY expression
I have to run a query to list the Product_code, stock_level, and the total quantity ordered
The tables are as follows:
PRODUCT:
PRODUCTCODE PRODDESCRIPTION PRICE STOCKLEVEL
p1 carpet 40 10000
p2 tile 20 100000
p3 pergo 50 50000
PRODLINE:
ORDERNUMBER PRODCODE QUANTITY
o1 p1 1000
o1 p2 500
o2 p3 200
o3 p1 600
o3 p3 100
o4 p2 1000
o5 p2 800
Here is my SQL Statement:
SELECT pl.PRODCODE, SUM(pl.QUANTITY), pr.STOCKLEVEL
FROM PRODLINE pl, PRODUCT pr
WHERE pl.PRODCODE=pr.PRODUCTCODE
GROUP BY pl.PRODCODE;
RESULT:
ORA-00979: not a GROUP BY expression
Can someone please assist?Welconme to the forum!
895231 wrote:
... Here is my SQL Statement:
SELECT pl.PRODCODE, SUM(pl.QUANTITY), pr.STOCKLEVEL
FROM PRODLINE pl, PRODUCT pr
WHERE pl.PRODCODE=pr.PRODUCTCODE
GROUP BY pl.PRODCODE;
RESULT:
ORA-00979: not a GROUP BY expression
Can someone please assist?Remember the ABC's of GROUP BY:
When you use a GROUP BY clause and/or an aggregate fucntion, then everything in the SELECT clause must be:
(A) an <b>A</b>ggregate function,
(B) one of the "group <b>B</b>y" expressions,
(C) a <b>C</b>onstant, or
(D) something that <b>D</b>epends entirely on the above. (For example, if you "GROUP BY TRUNC(dt)", you can SELECT "TO_CHAR (TRUNC(dt), 'Mon-DD')").
In your query, pr.stocklevel is none of the above.
The previous respondent show how you can make it one of the "group <b>B</b>y" expressions, which is noramlly how you would handle this situation.
Alternatively, you could make it an <b>A</b>ggregate function, like this:
SELECT pl.PRODCODE
, SUM (pl.QUANTITY) AS total_quantity
, MIN (pr.STOCKLEVEL) AS stokclevel
FROM PRODLINE pl
, PRODUCT pr
WHERE pl.PRODCODE = pr.PRODUCTCODE
GROUP BY pl.PRODCODE; -
Error when use"select case when sum() group by"
SELECT REGION_CODE
,REGION_DESC
,CASE WHEN SUM(UP_SMS_TIMES) BETWEEN T2.SMS_MIN AND T2.SMS_MAX THEN T2.SMS_LVL_CODE END
FROM PMID.TB_MID_PAR_EXT_USER_MON T1, PCDE.TB_CDE_SMS_LVL T2
WHERE DEAL_DATE='200811'
GROUP BY REGION_CODE, REGION_DESC
{color:#ff0000}error:ORA-00979: not a GROUP BY expression
{color}{color:#000000}How can i fix the error,Thanks{color}-- CREATE TABLE TB_MID_PAR_EXT_USER_MO
create table TB_MID_PAR_EXT_USER_MON
DEAL_DATE CHAR(6),
REGION_CODE CHAR(2),
REGION_DESC VARCHAR2(20),
UP_SMS_TIMES NUMBER(14) default 0,
--INSERT SAMPLE DATA TO TB_MID_PAR_EXT_USER_MO
insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
VALUES('200812','BJ','BEIJING'11)
insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
VALUES('200812','SH','SHANGHAI',7)
insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
VALUES('200812','SH','SHANGHAI',9)
insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
VALUES('200812','BJ','BEIJING',10)
insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
VALUES('200812','BJ','BEIJING',5)
insert into TB_MID_PAR_EXT_USER_MON(DEAL_DATE,REGION_CODE,REGION_DESC,UP_SMS_TIMES)
VALUES('200812','BJ','BEIJING',19)
---- CREATE TABLE TB_CDE_SMS_LVL
create table TB_CDE_SMS_LVL
SMS_LVL_CODE INTEGER,
SMS_LVL_DESC VARCHAR2(20),
SMS_MIN NUMBER(14,2),
SMS_MAX NUMBER(14,2)
--INSERT SAMPLE DATA TO TB_CDE_SMS_LVL
INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
VALUES(1,'0 ITEM',-1.00,0.00)
INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
VALUES(2,'0-20 ITEM',0.00,20.00)
INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
VALUES(3,'20-40 ITEM',20.00,40.00)
INSERT INTO TB_CDE_SMS_LVL(SMS_LVL_CODE,SMS_LVL_DESC,SMS_MIN,SMS_MAX)
VALUES(4,'40- ITEM',40.00,9999999.00)
--NOW,LET'S EXEC THE FOLLOWING STATEMENT
SELECT REGION_CODE,REGION_DESC
,MAX(CASE WHEN SUM(UP_SMS_TIMES) BETWEEN T2.SMS_MIN AND T2.SMS_MAX THEN T2.SMS_LVL_CODE END) AS SMS_LVL
FROM PMID.TB_MID_PAR_EXT_USER_MON T1,PCDE.TB_CDE_SMS_LVL T2
WHERE DEAL_DATE='200811' AND UP_SMS_TIMES>0
GROUP BY REGION_CODE, REGION_DESC
--MY REQUIRED RESULT IS
REGION_CODE REGION_DESC SMS_LVL
SH SHANGHAI 2
BJ BEIJING 4
Thanks you! -
ORA-00979: not a GROUP BY expression ORA-01722: invalid number error
This is my follwing code:
select isin,nomenclature,sum(total_balance),c_itd_rddt,c_itd_intrrt from
select distinct instru.c_int_isin isin,
instru.c_int_longdesc nomenclature,
to_char(abs(acpos.acp_totbal),
'999999999999,99,99,990.00')total_balance,
c_itd_rddt,
c_itd_intrrt
from cs_instru_t instru,
cs_instrudetls_t insdtls,
cs_acpos_t acpos
where instru.c_int_instruid = insdtls.c_itd_instruid
and acpos.acp_instruid = instru.c_int_instruid
and acpos.acp_acntnum = 'SG030001'
and instru.c_int_instypid in (1)
and insdtls.c_itd_rddt > ('31-Dec-2010')
and instru.c_int_isin not in
(select spsec.c_ssg_isinno from cs_splsecgrp_t spsec) and acpos.acp_totbal!=0
group by instru.c_int_instruid,
instru.c_int_longdesc,
insdtls.c_itd_rddt,
instru.c_int_insstts,
instru.c_int_isin,
insdtls.c_itd_rddt,
acpos.acp_totbal,c_itd_intrrt
--order by extract(year from c_itd_rddt),c_itd_intrrt
union
select c_srm_prntisin isin,c_int_longdesc nomenclature,to_char(abs(acpos.acp_totbal),
'999999999999,99,99,990.00') total_balance,c_itd_rddt,
c_itd_intrrt from cs_instrudetls_t insdtls,cs_strmap_t map,cs_instru_strips instru,cs_acpos_t acpos
where c_int_instruid=c_srm_prncplinsid
and c_itd_instruid=c_int_instruid
and c_srm_prncplinsid=acp_instruid
and acp_acntnum='SG030001'
)view1
group by isin
I want to group by isin only as only isin is same and the rest of the fields are different.But I want to display all the fields.Please Help
I am getting the following errors:
ORA-00979: not a GROUP BY expression
ORA-01722: invalid numberwat abt the other error ora-01722 not a valid number. How to take sum of total_balance which is to_char
-
Getting an error when using adobe photoshop CC, "Could not move the data because of a program error". Any idea on what this means?
Have no idea of what you were even doing in Photoshop my crystal ball is out for repairs so I can not see.
-
RPC Server not Available error when using Windows Fax & Scan under Windows 7
RPC Server not Available error when using Windows Fax & Scan under Windows 7
Hi,
On current situation, please remove the old fax account and re-add a new fax account in Windows Fax and Scan, then check if this issue sill exist. For more details, please refer to following similar thread and artilces.
RPC Server not Available error when using Windows Fax & Scan
under Windows
The local fax account is inaccessible after you rename a Windows Vista-based computer
Cannot send fax from Windows Vista/Windows 7 PC with “RPC Server not Available” error message
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please
make sure that you completely understand the risk before retrieving any suggestions from the above link.
If any update, please feel free to let me know.
Best regards,
Justin Gu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Revision: 21394
Revision: 21394
Author: [email protected]
Date: 2011-06-16 12:34:13 -0700 (Thu, 16 Jun 2011)
Log Message:
bug fix for watson 2887837 Not getting duplicate session detected error when same flex client id is used from two different HTTP sessions in CRX.
get the sessions id before we invalidate the duplicate session.
Checkintests pass
Modified Paths:
blazeds/trunk/modules/core/src/flex/messaging/endpoints/BaseHTTPEndpoint.javaFor our profect I think this issue was caused as follows:
Believing that remoting was full asynchronous we fired a 2 or 3 remote calls to the server at the same time ( within the same function ) - usually when the users goes to a new section of the app.
This seemed to trigger the duplicate http session error since according to http://blogs.adobe.com/lin/2011/05/duplication-session-error.html two remote calls arriving before a session is created will cause 2 sessions to be created.
Our current solution ( too early to say it works ) is to daisy chain the multiple calls together .
Also there seemed to be an issue where mobile apps that never quit ( thanks Apple! ) caused the error when activated after a few hours.
I guess the session expires on the server and the error above occurs on activation.
So the mobile apps now ping the server with a remote call when activated after sleeping for more than one hour.
All duplicate http errors are silently caught and reported.
Fingers crossed we won't get any more!
Maybe you are looking for
-
What happened to the sent items configuration in Exchange 2013?
Why is Set-MailboxSentItemsConfiguration removed from Exchange 2013? It was a really useful feature... Does anyone know if it will reappear? I know I can make a gpo and roll out the DelegateSentitemsStyle but I prefer using the setting in Exchange.
-
GMail wont work on firefox due to cookies
For those who have had a Firefox wont let GMail ope due to cookie and redirection problem. I have just adjusted the Accept third party from the site visited instead of Always or never. After that I closed and restarted my browser and Voila! I now hav
-
I am trying to change the "Full Name" under Users and Groups. When I type in my actual full name, it says "Name is used by another User. So I had to enter just my first name. FYI, In the left column, the only user is the one with my first name and G
-
Build essbase cube using Sql query.....
Hi Team, Can we build dimensions as well as load data into essbase cubes using sql query generated from cognos cube. If so , please guide me the procedure
-
I upgraded to Yosemite. Then of course i photo does not work.. I went to the app store. told the system to download the app. Its a huge app. 1.2gig. then nothing. for two days.. I have a box in preview that says op_Iphoto_loading.prig and it ha