Problém je v tom, že objednáváte podle něčeho, co není ve vaší group by klauzule.
Například toto funguje
SQL> with testGroup as ( select 1 as one, 2 as two from dual)
2 select one
3 from testGroup
4 group by one;
ONE
----------
1
Pokud order by sloupec, který není ve vaší group by klauzule:
SQL> with testGroup as ( select 1 as one, 2 as two from dual)
2 select one
3 from testGroup
4 group by two;
select one
*
ERROR at line 2:
ORA-00979: not a GROUP BY expression
Pokud upravíte group by klauzule pro zpracování sloupce, který potřebujete v order by :
SQL> with testGroup as ( select 1 as one, 2 as two from dual)
2 select one
3 from testGroup
4 group by one, two;
ONE
----------
1
SQL>