Masalahnya adalah Anda memesan berdasarkan sesuatu yang tidak ada dalam group by
klausa.
Misalnya, ini berfungsi
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
Jika Anda order by
kolom yang tidak ada dalam group by
klausa:
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
Jika Anda mengedit group by
klausa untuk menangani kolom yang Anda butuhkan dalam 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>