Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

"ORA-00979: not a GROUP BY expression" error without a GROUP BY...?

BrennMay 6 2019 — edited May 6 2019

Hi everyone !

I'm having some serious issues for some days with this simple query :

INSERT INTO WM040P66 (CSTE,CETAB,CDEPOT,NUMINV,L17PAL,DPSECT,DPAGEO,CDART,VL,VA,LTNLOT,LTNLOS,TYPLI,REQP66)

SELECT CSTE, 'E10', CDEPOT, 1076, L17PAL, ' ', ' ', ' ', 0, 0, 0, 0, '3', 5 FROM V62FICFOR1.SM017V16

WHERE CSTE = 'OR10' AND CDEPOT = 'D11';

I have a "ORA-00979: not a GROUP BY expression" error when running this query, but if I remove the INSERT part, the SELECT query works fine.

This is an Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production. WM040P6 is a table and SM017V16 is a view. I also made sure every type matches.

I can't really say what the query is supposed to accomplish, this database is a huge mess, and I don't have time to learn how it all works. This query is from a software that I'm trying to debug (and this is an issue).

SM017V1 view definition :

CREATE OR REPLACE FORCE EDITIONABLE VIEW "V62FICFOR1"."SM017V16" ("CSTE", "CDEPOT", "L17PAL", "NBEMPL") AS

WITH TEMP AS(

    SELECT CSTE , CDEPOT , DPSECT , DPAGEO , L17PAL

    FROM V62FICFOR1.SM017P10

    WHERE L17PAL <> ' ' AND LTCANN = ' ' AND (LTQDIS + LTQRSR) <> 0

    GROUP BY CSTE, L17PAL, CDEPOT, DPSECT, DPAGEO)

SELECT CSTE, CDEPOT, L17PAL, COUNT(*) AS NBEMPL

FROM TEMP

GROUP BY CSTE, CDEPOT, L17PAL

HAVING COUNT(*) > 1

(I know there are 2 GROUP BY but the SELECT query works fine, so I don't think the issue is from this query. I don't see any error in this query too)

Any idea on what/where is the issue ?

Comments
Post Details
Added on May 6 2019
3 comments
3,121 views