Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Wrong Results in simple max() Statement


We use MaxDB

On our Datbase I used the following Query :

select max(ROID) FROM READOUT WHERE AMID = 101721 AND STATE IN ( 'K','M','C' )

and got the Result:



This is wrong what I checked via :

select * FROM READOUT WHERE AMID = 101721 AND STATE IN ( 'K','M','C' )


my quick solution was to use:

select max(ROID),max(ROWANN) FROM READOUT WHERE AMID = 101721 AND STATE IN ( 'K','M','C' )

with the result:


7235411               2013-11-22 09:02:38.0

And the Value 7235411 was the one I expected and is obviosly greater than 2153087

but what happens there, and how could we make shure that we dont have same effects in other ends of our Application

I guess it might be tha case if alle Values could be catched out if the index.

The Query Plan is:

SCHEMANAME     TABLENAME     COLUMN_OR_INDEX     STRATEGY                                   PAGECOUNT

MDR                    READOUT          RO_STATE                    RANGE CONDITION FOR INDEX;     14229

                                                                                          ONLY INDEX ACCESSED;

                                                                                          MIN/MAX OPTIMIZATION;

                                                                                          AMID;     (USED INDEX COLUMN);

                                                                                          STATE;     (USED INDEX COLUMN);

                             JDBC_CURSOR_218                              RESULT IS COPIED   , COSTVALUE IS;         3

With index :

create index "RO_STATE" on "MDR"."READOUT" ("AMID" ASC,"STATE" ASC)


Any Idea ?

Former Member
Not what you were looking for? View more on this topic or Ask a question