BJCooperIT
Programmer
In previous versions of Oracle it was never necessary to code an Order By clause if your Group By clause matched the sequence in which you wanted the data. This appears to have changed in 10g:
My question is whether this a bug or a feature? If a feature, why? It appears that developers need to review all existing queries when upgrading to 10g.
Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
Code:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
SQL> create table bjc_test (fld1 varchar2(05), fld2 varchar2(05));
Table created
SQL>
SQL> insert into bjc_test values ('DEF','001');
1 row inserted
SQL> insert into bjc_test values ('DEF','007');
1 row inserted
SQL> insert into bjc_test values ('DEF','005');
1 row inserted
SQL> insert into bjc_test values ('ABC','060');
1 row inserted
SQL> insert into bjc_test values ('ABC','005');
1 row inserted
SQL> insert into bjc_test values ('ABC','040');
1 row inserted
SQL>
SQL> select FLD1, FLD2 from BJC_TEST
2 group by FLD1, FLD2
3 /
FLD1 FLD2
----- -----
[B]DEF 007
ABC 005
DEF 005
DEF 001
ABC 040
ABC 060[/B]
6 rows selected
SQL>
SQL> select FLD1, FLD2 from BJC_TEST
2 group by FLD1, FLD2
3 order by FLD1, FLD2
4 /
FLD1 FLD2
----- -----
ABC 005
ABC 040
ABC 060
DEF 001
DEF 005
DEF 007
6 rows selected
SQL>
Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus