Problem polega na tym, że zamawiasz przez coś, czego nie ma w Twojej group by
klauzula.
Na przykład to działa
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
Jeśli order by
kolumna, która nie znajduje się w Twojej group by
klauzula:
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
Jeśli edytujesz group by
klauzula do obsługi potrzebnej kolumny w 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>