Hello experts!
I'm facing a problem in ABAP SQL, and don't know, whether it's some kind of undocumented feature, or is my database system doing something strange. The issue can be observed by selecting data with GROUP BY addition, but without ORDER BY addition.
Here's my code:
SELECT tabclass,
MIN( as4date ) AS as4date_min,
MAX( as4date ) AS as4date_max
FROM dd02l
INTO TABLE @DATA(g_dd02l)
WHERE tabname LIKE 'DD%'
GROUP BY tabclass.
In my 7.40 systems: SP09 and SP12 with MaxDB the results here are as expected: four lines in alphabetical order: APPEND, INTTAB, POOL (only by SP12), TRANSP, VIEW.
But if I change the code slightly:
SELECT tabclass FROM dd02l INTO TABLE @DATA(g_dd02l) WHERE tabname LIKE 'DD%' GROUP BY tabclass.
I get different order, namely POOL (only SP12), VIEW, APPEND, INTTAB, TRANSP. Why?
I have checked the same in customer systems: 7.40 SP14 with DB6, 7.50 SP22 with DB6 and 7.50 SP23 with ORACLE, and there is no difference between those two codes.
On the other hand, in customer system 7.52 SP09 with MaxDB the results are same as in my both systems. I thought, it would be a MaxDB issue. But then I came across customer system 7.31 SP29 with DB400. Here the results, for both codes, are as follows: VIEW, INTTAB, APPEND, POOL, TRANSP.
What is the reason for this sort order? Maybe the sort order by using GROUP BY is not given, just like by DISTINCT. But by DISTINCT it's explicitly documented, and by GROUP BY ìt's not. Why does the sort order depend on whether aggregate functions are used or not? Any clues?