Problemet är att du beställer efter något som inte finns i din group by
klausul.
Detta fungerar till exempel
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
Om du order by
en kolumn som inte finns 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
Om du redigerar group by
för att hantera kolumnen du behöver 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>