Search notes:

ORA-00979: not a GROUP BY expression

A select with a group by clause requires all non-aggregated columns to be also present in the group by clause, otherwise, Oracle throws a ORA-00979: not a GROUP BY expression error message, as demonstrated below:
create table tq84_00979 (
    val    number,
    grp_1  varchar2(10),
    grp_2  varchar2(10),
    col    date
);

--
--  Cause ORA-00979
-- (column grp_2 is selected but
--  not part of the group by
--  expression)
--
select
   max(val),
   grp_1,
   grp_2
from
   tq84_00979
group by
   grp_1;

--
-- This one is OK
--
select
   max(val),
   grp_1,
   grp_2
from
   tq84_00979
group by
   grp_1,
   grp_2;

--
-- This one also causes an ORA-00979 because
-- of the col expression in the order by clause
--
select
   max(val),
   grp_1,
   grp_2
from
   tq84_00979
group by
   grp_1,
   grp_2
order by
   col;

drop table tq84_00979;

Improved error messages in 23c

The ORA-00979 error message belongs to the error messages that were improved in the 23c release: in this release, it now lists the (first?) expression missing in the group by clause.

See also

ORA-00937: not a single-group group function
Other Oracle error messages

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759038607, '216.73.216.5', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/errors/ORA-00979_not-a-GROUP-BY-expression(96): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78