Solve the paging error caused by inconsistent sorting fields using rownum in oracle. Recently, when I wrote a list component ulynlist, I detected a problem and recorded it here. Today, when I called the list component, I tried to lower the number of items and each page. When I finished the plug-in of the paging foot, I was very happy, suddenly, I found out how the data was always written by the front-end plug-in. Later, I went to the SQL statements in the console and cut out the SQL statements for execution. I found that from 9 to 13 is the same record.
1 SELECT * FROM (select. *, rownum rn from (2 select t. * from T_CAR_INFO t WHERE t. del = '0' AND t. id = '003 '3 order by CREATE_TIME desc) a where rownum <= 10) where rn> = 10
Normally, this SQL statement is difficult to find out what is wrong. In general, the CREATE_TIME in our small-traffic system is often unique, so it is really difficult to find out. I use CREATE_TIMEDESC for sorting, but the value of this field is copied and pasted because it is filled by the database record. Many records have the same value. This is a typical case where the order by field value is not unique, resulting in confusion in paging records. How can this problem be solved? In fact, it is very simple. You only need to add a field with unique values during sorting. Preferably id. Changed to the following to find that everything is normal:
1 SELECT * FROM (select. *, rownum rn from (2 select t. * from T_CAR_INFO t WHERE t. del = '0' AND t. id = '003 '3 order by CREATE_TIME desc, id) a where rownum <= 10) where rn> = 10