Problemet er, at du bestiller efter noget, der ikke er i din group by
klausul.
For eksempel virker dette
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
Hvis du order by
en kolonne, der ikke er i din group by
klausul:
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
Hvis du redigerer group by
klausul for at håndtere den kolonne, du har brug for i 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>